xenapi: remove propagate xenapi_use_agent key

The compute.api class will already propagate then xenapi_use_agent key
when required, so we can remove the xenapi specific code that tries to
propagate this value. The code did not correctly access the system
metadata, would have failed to propagate the key anyway.

Fixes bug 1204933
Change-Id: Ib291a265318d80705129e565155d4250fd704b75
xenapi: remove pv detection

It was assumed that pygrub is there in domU, so that the RAW and unknown
disks were attached to domU and investigated with pygrub to find out if
PV could be used. This patch removes this functionality. Also some
cleanup is made around the ImageType mess.

From now RAW and unknown disks will not be investigated for PV-ness and
will boot as HVM.

Fixes bug 1196570

Change-Id: If84b93cee36938257b7ad0fa44b3b22878520506
xenapi: no image upload retry on certain errors

There are a few upload errors that glance plugin should
not retry upload on, as it will fail again. This patch changes
upload to not retry on the following conditions in addition
to the 401 error that it already handles:

- CONFLICT
- REQUEST_ENTITY_TOO_LARGE
- PRECONDITION_FAILED
- FORBIDDEN

Fixes bug 1203726

Change-Id: I538a4f9b133169b2e398e7dfcb3af58fef204f03
Fix instance_usage_audit_log v3 follow REST principles

Use query parameter 'before' instead of show.
BTW, add expected_errors decorator.

Partially implements bp v3-api-extension-versioning

DocImpact

Change-Id: If1168c01e6342675370acdf278e1c0317aff93d8
Raise 404 when instance not found in admin_actions API

The pause/unpause/suspend/resume/reset_network admin action APIs do not
handle the case where the instance in the request is not found and they
raise HTTPUnprocessableEntity (code 422) instead. There are several
other operations in the same API which handle the 404 case and translate
it correctly, this patch cleans up the rest.

Closes-Bug: #1204999

Change-Id: If54d6be99db55b4f99da11fe75c14bf21685e809
remove improper usage of 'assert'

The assert will not raise AssertionError when run Python with '-O' flag.
And at the same time, any program should have a same result with or
without '-O' flag. So we could use assert to check some rare condition,
but we couldn't use it in logic flow or except it must raise an
Assertionerror, for example:

this is not bad:

def func(fname):
    assert os.path.exist(fname)
    f = open(fname)
    ...

but this will have different results with or without '-O' flag

def func(num):
    try:
        assert num is 5
    except: Assertionerror:
        log.error("your number isn't 5!")

The second case is what I fixes in this patch.

fixes bug #1199354
Change-Id: I20e83ecfc181d213f357aa74e0af3a110526904c
Add expected_errors for extension baremetal v3

Partially implements bp v3-api-extension-versioning

Change-Id: I294aa1cb4e19aba755d8c2c78fd997c7e447204e
Add expected_errors for extension Console v3

Partially implements bp v3-api-extension-versioning

Change-Id: Ie4c20eb494c68b0d75114872ae7b227da286d609
Add expected_errors for extensions simple_tenant_usage v3

Partially implements bp v3-api-extension-versioning

Change-Id: I69d17279f4c8efe13289458fc4aa583b9168fcc7
Fix Instance objects with empty security groups

This makes sure that a DB instance with an empty list of security
groups does not result in an object with an unset attribute, thus
triggering a lazy load on access (and ultimately an exception).

Related to blueprint compute-api-objects

Change-Id: Ib33b05853e9d067cbac5d3e87824a68e9935b822
xenapi: Adding BitTorrent download handler

Part of series of patches which extends uploadhandler driver-pattern to also
handle downloads.

DocImpact

Change-Id: Ic5445167bb425c9ba910039db182783a2f1defdd
Fix typo in compute.rpcapi comments

Change-Id: I76a60b29352e023e5c72d546e144eb330b218b64
Fix instance actions testing

Somehow, the instance actions API was different in three places:

1. The actual API from a running system
2. The regular unit tests
3. The api_samples tests

This fixes the fake_instance_actions module to look like the database
model (which was the root of the problem) as well as the api_samples
and regular unit tests to properly confirm the actual behavior I
validated manually against a running system. This looks like it
changes the external API, but in fact, it makes things match what
the external API actually is.

Change-Id: I0c8ddff3e0819a65667617083dfaa74f7317cc05
Make fake_instance handle security groups

This makes the fake_db_instance() helper create model-like security
group objects in the returned instance if a list of names is
specified. This is required to test anything that uses security
groups on the instance.

Related to blueprint compute-api-objects

Change-Id: I4a7d91c939af8c0dc4e0b3e29c477a859d85fd3e
Pull out instance object handling for use by create also

The instance_create() function needs the same type handling
logic to tolerate object-initiated creates as does instance_update().
This pulls that logic out to a common function and makes both of
them use it.

Related to blueprint compute-api-objects

Change-Id: Ie8612ffb225b95bf7eab3c462441665095ed19bc
Add Instance.create()

This adds a create method to the Instance object and associated
tests.

Related to blueprint compute-api-objects

Change-Id: I0e530df042eaf6f646e8ac94bb956d3d427ae333
Merge "Add expected_errors for extension baremetal v3"
Merge "Add expected_errors for extensions simple_tenant_usage v3"
Merge "xenapi: remove pv detection"
Remove dead capabilities code

Although the scheduler.host_manager has logic to handle the
'allowed_vm_type' capabilities, no virt driver supports that capability.
So just remove the dead code.

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

Change-Id: I223fc10a27291d88d0e12057504525233ab845ad