Use poll instead of threading.Event in heartbeat thread

poll() does not rely on absolute time.
This fixes an issue where the system clock may be changed, and
the heartbeat thread would stop heartbeating.

This also gives us flexibility to force a heartbeat in a later
change.

Change-Id: Ifde7b53f59788addc43a5dac95c7b6519d87e834
Closes-Bug: 1355375
Force heartbeat immediately after async command completes

This change passes the agent object into extensions, such that
they may call agent methods as needed. It also causes async
commands to force a heartbeat immediately after completing the
command. This allows Ironic to get a heartbeat and continue
work as quickly as possible, while also allowing deployers to
configure Ironic (agent) to heartbeat less often.

Change-Id: Ib3c3a43dfd0ed4ed51b7d52ac099f01181ca822f
Use LLDP to get switch port mapping

Provides a function to listen for LLDP packets on the network.
Listens on one or all of the network interfaces, and then parses the found
packets.

Change-Id: I1545a41f46cd0916aab9c43ce036865454fa66e0
Co-Authored-By: Josh Gachnang <josh@pcsforeducation.com>
(cherry picked from commit 69904ed077c9ad4cd60469f96f26b63565e45f9e)
Adding support for decommissioning

The pluggable hardware manager should be able be used for decommissioning,
such as erasing disks, updating firmwares, changing BIOS settings, and
anything else specific hardware needs. This works with the agent driver
to store state in Ironic and request out of band reboots (which may be
required to make BIOS/firmware updates work). Also allows the agent to do
some basic verification of the node's properties, to ensure they haven't
changed, such as a stick of memory dying.

Change-Id: Ia42a8e75d2b8887b2351de97c2137fe21a7f4041
Add versioning to Agent decommission

As the agent will likely be rebooting while decommissioning (to apply BIOS/
firmware upgrades), it is possible the version of the agent will change
between boots. Including a version string in the Hardware Manager allows
the Hardware Manager builder to bump versions for any breaking changes.
I recommend that the entire decommission process be restarted if there
is a version mismatch, but that will be up to individual drivers to
implement.

This change also adds a new return value for Agent REST commands called
'DECOM_VERSION_MISMATCH' that will signal no command was run, and
Ironic should update its stored value. A 'hardware_manager_version'
will be returned with AsyncCommandResult, and should be set in the
Ironic driver_info field and sent with any decommission command.

Change-Id: I2ae0e93573e0348f023aa124a07bb16921b5c53e
(cherry picked from commit 412174cc9acdc43095147aa63ce1f182af7ca7a3)
Use poll instead of threading.Event in heartbeat thread

poll() does not rely on absolute time.
This fixes an issue where the system clock may be changed, and
the heartbeat thread would stop heartbeating.

This also gives us flexibility to force a heartbeat in a later
change.

Change-Id: Ifde7b53f59788addc43a5dac95c7b6519d87e834
Closes-Bug: 1355375
(cherry picked from commit 4f57590b2e41863770b764a8b84b8b81830ad577)
Add command metrics to IPA API

This will allow the agent to report timing and counter data for commands
that are run on the agent (starting with Standby commands). It will allow a
properly configured agent to send metrics to a remote or locally packaged
statsd. It is also extensible, so other metrics systems can easily be used.

Change-Id: Ic08d4ff78b6fb614b474b956a32eac352a14262a
(cherry picked from commit 0807dedb925dac2da36c0e38f1d50cf8d3dd4008)