Unimplemented suspend/resume should not change vm state

When the underlying virt driver does not implement the suspend/resume API
and raises a NotImplementedError, the compute manager will error out and
change the instance's vm_state to ERROR. With this change, the compute
manager will handle the NotImplementedError and keep the instance
vm_state as it was before the error.

Change-Id: I8150a898fee91bbe66f1502638baca8050e2dd6d
Fixes: bug #1203986
Adds Instance UUID to rsync debug logging

This commit adds the instance uuid to the rsync debug output in
the debug logs. The issue we were seeing is that when multiple
migrations are ongoing at the same time, it's not easy to
track the rsync progress of each migration.
Fixes: bug #1215629

Change-Id: Iec662bdc0aed1c6f54ecaa062335dc5504ac030f
XenAPI: Generic Fake.get_all_records_where implementation

Tests were incorrectly passing due to bad implementations.

Note that link to xenserver-core blueprint is due to patch following this
change

Implements blueprint xenserver-core

Change-Id: I051877551611e001295403af8369bcc97c8ba0fb
XenAPI: SR location should default to location stored in PBD

This value must be read from the PBD as it may change for different
installations.  The existing default is preserved as a fallback
for the cases where a PBD path is not set.

Implements blueprint xenserver-core

Change-Id: I055ebe8d7d79f238b0b9565277acac945bbe12e1
powervm: revert driver to pass for plug_vifs

Change Ieaf256a5c0f54804686318d6cbd5877a5003c9eb made the powervm driver
plug_vifs method raise NotImplementedError rather than pass, which is
what the hyper-v and vmware drivers do for plug_vifs. This results in
the compute manager failing to init the host because it's not catching
NotImplementedError from driver.plug_vifs.

This patch simply changes the powervm driver plug_vifs method back to
the old behavior (pass), but at least logs a debug message this time.

Closes-Bug: #1217586

Change-Id: Iafe87cbb9b3cf728a47cb9cc43151798fcbb780f
PCI devices resource tracker

PCI device need to be scheduled according the resource status. The PCI
tracker provoides central contorl of the PCI resouces.

Discovered PCI devices are passed to the PCI tracker to track their status,
and to provide functions for compute node components to update, check, claim
the PCI devices resources.

PCI Tracker also updates PCI stats which provide infomation to the scheduler.

bp:pci-passthrough-base

Change-Id: Ia80633b5a52b88fd7c9aea168644283b00be0b49
Signed-off-by: Yongli He <yongli.he@intel.com>
Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Add PCI device tracker to compute resource tracker

PCI device tracker manages all the PCI devices life cycle.

The resource tracker on a compute node uses the PCI device tracker's
interface to query for resources, claim PCI devices, and alloc and
free PCI devices for instances.

bp:pci-passthrough-base

Change-Id: I766d7f92e26fb75c1d6095dc0237c44f938d4170
Signed-off-by: Yongli He <yongli.he@intel.com>
Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
xenapi: agent not inject ssh-key if cloud-init

It is possible to have an image with both the xenapi agent and
cloud-init present, or an alternative agent that makes use of metadata
to configure a server.

To ensure the agent will not clash with the ssh key and file injection
of the agent, I have added image properties so we can disable these
agent operations on a per image basis.

The image properties this new code looks for are:
xenapi_skip_agent_inject_ssh=true
xenapi_skip_agent_inject_files_at_boot=true

DocImpact
Part of blueprint xenapi-guest-agent-cloud-init-interop
Change-Id: I416ade49663208769571fe0c9cf22c8fc1360244
Fix and gate on H302 (import only modules)

H302 is already part of the OpenStack style guide, and we only had a few
violations.  This fixes and gates on H302, so there is one less thing
for a reviewer to worry about.

gettext import line is ignored using hacking 0.7's import_exceptions
option.

Reason for import only modules 'The namespace management convention is
simple. The source of each identifier is indicated in a consistent way;
x.Obj says that object Obj is defined in module x.'
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html

Change-Id: I53e8039f1dd2ebf8ab5fcf5a561feb3ca3363107
Fix usage of classmethod in various places

The decorator @classmethod isn't always correctly used in the code base,
this patches fixes some places where it was not used correctly.

Change-Id: Ifd4113b693889de0becc37854f4c62faf2fdab11
powervm: make start_lpar timeout

This patch makes the start_lpar method timeout like the stop_lpar
method.

Change-Id: I111ed7ee80f7a9e786d8cb8b02747b5187120858
Merge "powervm: revert driver to pass for plug_vifs"
Merge "powervm: make start_lpar timeout"
Merge "Fix usage of classmethod in various places"
Merge "xenapi: agent not inject ssh-key if cloud-init"
Merge "XenAPI: Generic Fake.get_all_records_where implementation"
Merge "XenAPI: SR location should default to location stored in PBD"
XenAPI: make_partition fixes for Dom0

When running in dom0, the calls to parted fail to re-read the partition
table so we have to use kpartx to read it specifically.

The failure to re-read the partition table also means that the exit code
is non-0.

Implements blueprint xenserver-core

Change-Id: I56ca25874d6491b0ed70e5efd477254bfe47294d
XenAPI: More operations with LVM-based SRs

Some operations require Files-based SRs (ext3/NFS) - such as resize
and VHD download.  However, if using 3-part images or RAW then most
operations can be successful with this simple fix.

Fixes bug 1162382

Change-Id: Ia3d1c64871d78ab1bf6e197edaeee170d2b5dea8
Make compute_capabilities_filter use information from DB not RPC

Make compute_capabilities_filter directly use the data in host_state and
not the data capabilities data that is currently broadcast from the
schedulers over RPC, as this will be removed since it doesn't scale.

The filter name, compute_capabilities_filter, is kept the same to keep
backwards compatibility.

This is a second attempt at this patch the first one broke the ability
to filter an arbitrary key value pairs, this time that is supported via
host_state.stats, along with tests to confirm

Once all the capabilities usage in scheduler filters is removed, the
capabilities RPC broadcast can be removed.

Part of bp no-compute-fanout-to-scheduler.

Change-Id: I0b9b05a25a8c1841093913c4a2fb19b48aff2ae1