Fix one port can be attached to more devices

a port attached to some device should not be attached to another device again

Change-Id: I60de0fa265358ac5b5e1b2c8f370862b32f9e724
Fixes: bug #1204850
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
Fixes missing host in Hyper-V get_volume_connector

Fixes bug: #1215765

The Hyper-V driver is not returning the host in the
"get_volume_connector" method.

This commit fixes the issue by adding the "host" key to the dictionary
returned by the method.

Adds also a unit test for get_volume_connector.

Change-Id: Ic74882e54994f957bf6d2bb75bbd53c6a346042e
compute rpcapi 2.37 is not backwards compatible

Patch 552693e4ad51291c8bfd28cd1939ed3609f6eeac which added compute
rpcapi version 2.37 does not provide any backwards compatibility.

Fix the issue by 'self.can_send_version'.

Fix bug 1217044

Change-Id: I65154fa6298133721b6509b00b117d7f6cc455b8
Improve db_sqlalchemy_api test coverage

Added new tests and improved coverage for methods:

 instance_group_*
 migration_*
 task_log_*
 agent_build_*

Blueprint: db-api-tests

Change-Id: Idbf704b3e6aa8df1d4f927e67d108e6a8489b9d2
powervm: actually remove files after migration

The powervm driver is attempting to clean up compressed image gz files
in the migration flow but the rm command being issued doesn't use the
--force option, so the files are piling up on the backing hypervisor.

This patch properly removes the files like in other parts of the powervm
code (see blockdev.py for example) and fixes the tests so the
_remove_file method is actually tested.

Closes-Bug: #1214985

Change-Id: I82919aa20447230e317c13f51bdf1c204a2eca39
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>
Tenant id filter test is not correct

The test_tenant_id_filter_converts_to_project_id_for_admin is not testing what
it is reporting.
To test that the tenant_id filter is actually mapped correctly to the
project_id filter, the request has to include the all_tenants options too.

That should be make clearer how the tenant_id option actually works.

Change-Id: Id6e8c9d2f39d4dd7ce3bb60400d9cf52c9133f48
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
Adds V3 API samples for agents, aggregates and certificates

Adds v3 API samples for the agents, aggregates, and certificates
extensions. Bundling them together to save on review load

Partially implements blueprint v3-api-unittests
Partially implements blueprint v3-api-specification

Change-Id: Iee26fe25b5fd369f2a1f5690ddc095a90526a549
Remove dis/associate actions from security_groups v3

In v3, with the imminent deprecation of nova-network, we're
removing Nova API extension actions that don't add value to
what's already offered by the source API (Neutron).

Partially implements blueprint nova-v3-api

Change-Id: I3b75143cd13faab5b1eb6f832876d29636e76fd0
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
Introduce InvalidPermission.Duplicate EC2 error code

New SecurityGroupRuleExists exception with 'InvalidPermission.Duplicate'
ec2_code attribute replaced useless EC2APIError.

Note that this error isn't about duplicate group as the code suggests,
but about duplicate permission within a group.

Implements: blueprint ec2-error-codes

Change-Id: I42c94e15a6ca1bc57b10fb683bec17b73de0e0e5
Use ExceptionHelper to bypass @client_exceptions

Rather than stubbing out catch_client_exception() to bypass the wrapping
of exceptions in ClientException, use the existing ExceptionHelper to do
it.

This is important for oslo.messaging, because there's no public API
method for us to stub out.

This is a continuation of I32c83ef15fece35526739c4fcdfccf7a275c7033 as
another stub_out_client_exceptions() usage got merged by
I4120156db1499dfd3ed22095e528787eb73d33a6.

blueprint: oslo-messaging
Change-Id: If4ff9dba58e9f94fab80be804a98c76fff3267b7
Fix warning log message typo in resource_tracker.instance_claim

Just cleans up a small typo in a warning log message that the resource
tracker gives when 'node' is already set on the instance during a claim
operation.

Change-Id: Ic1ece4451f54f4efc8028f8d90de5d240910b20e
Call safe_encode() instead of str()

To avoid the error in python2.6:
"UnicodeEncodeError: 'ascii' codec can't encode characters",
use safe_encode() to encode basestring instead of str().

Fix bug #1218719

Change-Id: Id26f23ad7f975a3a50750927adbedb86bf80871d