xenapi: deal with reboots while talking to agent

The latest version of the agent has started changing the hostname
through the official windows APIs, when resetnetwork is called. This
means a reboot might happen after resetnetwork.

A reboot happens when polling for the version. Until now we wait for the
call timeout, before fetching the new dom id. This change ensures that
if we spot a reboot, the plugin exits early rather than keeping polling
the wrong dom id.

Turns out its best to wait for the dom_id to change, before trying
to poll the agent again. Once the dom_id in xenapi has been updated,
the xenstore keys are always in place.

Trying too early leads to lots of reboot detections because we are
retrying with the old dom_id. XenServer continues to return the old
dom_id for a little while after the reboot.

Closes-Bug: #1370999

Change-Id: Id0bf5b64f2b271d162db5bbce50167ab1f665c87
VMware: remove unused variable from tests

Commit 6c4b89a2ad51f92707acc01908b63bc507ad8fe7 added a variable
which was never used.

Change-Id: I6d9391359f25feedbdf822a606c07b0ae9a735be
Fix broken cert revocation

Cert revocation was broken by
32b0adb591f80ad2c5c19519b4ffc2b55dbea672.  os.chdir() never returns
anything, so this method would always raise an exception.  The proper
way to handle an error from os.chdir() is to catch OSError.

There were existing tests for this code, but they conveniently mocked
os.chdir() to return values that are never actually returned.  The
tests were fixed to match the real behavior.

Change-Id: I7549bb60a7d43d53d6f81eecea31cbb9720cc8b6
Closes-bug: #1376368
Break out over-quota processing from quota_reserve()

This moves the over-quota processing out of quota_reserve and into a
private method.

This completes the refactor of the quota_reserve method to isolate the
large chunks of logic into separate private methods.

Closes-Bug: #1369605

Change-Id: Ic910ea042dfe50209f79928e61b3b34b4c734e73
Log quota refresh in_use message at INFO level for logstash

Commit 5aef26496786c02a1ed324bbd2eb0b9994a2018d added the log message to
give some idea when we're unnecessarily refreshing quota usage.

Logstash only collects INFO+ level messages, so bump this to an INFO
level message so we can track gate runs to see if this is actually a
problem.

Related-Bug: #1353962

Change-Id: I60ffa9dbda22e252f290bf316fa2e472d3e92f2f
Break out over-quota calculation code from quota_reserve()

The list comprehension used to create the overs list was really hard to
read, so this moves that code into it's own helper method and breaks out
the logic from the list comprehension, and adds unit tests.

Partial-Bug: #1369605

Change-Id: I44236c7a206b2a9bd3843c9ca2ce56591a66352f
Merge "Fix broken cert revocation"
Refactor of test case of floating_ips

This patch is prepare for porting floating_ips to v2.1,
and make v2.1 and v2 share same test cases.

Change-Id: I7ba202adeb7d65f1e04c36e8db647565c1fcaeb2
Merge "VMware: remove unused variable from tests"
Merge "Refactor of test case of floating_ips"
Merge "Break out over-quota processing from quota_reserve()"
Merge "xenapi: deal with reboots while talking to agent"
Fix pci_request_id break the upgrade from icehouse to juno

commit a8a5d44c8aca218f00649232c2b8a46aee59b77e add pci_request_id
as one item for the request_network tuple. But the icehouse code
assume only three items in the tuple.

This patch filters pci_request_id out from the tuple.

Change-Id: I991e1c68324fe92fac647583f3ec8f6aec637913
Closes-Bug: #1377447
Merge "Fix pci_request_id break the upgrade from icehouse to juno"
Merge "Log quota refresh in_use message at INFO level for logstash"
Merge "Break out over-quota calculation code from quota_reserve()"