Use 201 instead of 200 for action create of flavor-manage v3

All of v3 create action should return 201. Fix this for flavor-manage v3

Closes-bug: 1252162
DocImpact

Change-Id: I4fc698abdf89c93cb6ea0990ae43960f8c651d95
Clean up unused variables

This just removes a few variables that were unused and makes my linter
happy.

Change-Id: I0bc9fc1474e15801e4df84f78636c96ea1f916ff
Fix sample parameter of agent API

The parameter of agent update API has been changed from "para" to
"agent" since Nova v3 API, and this patch fixes the sample doc.

Partially implements blueprint v3-api-specification

Change-Id: Ic9c0f11a637e48daa9457ab9ae923fefc0fb350d
Libvirt:Instance resize confirm issue against NFS

when I test resize-confirm on NFS (KVM) using at least two
compute nodes, OSError will occur when try to cleanup the
backup instance directory and will make instance status
"Error".

One way to cleanup resize is using delay_on_retry and
maximum attempts setting. Replace rmtree() because
execute() have more parameters choices.

Closes-Bug: #1248019

Change-Id: Ifb9a500bbba805af0317307c2e7d6903dcd02ad1
Removes os-personalities extension from the V3 API

As per the discussion on the mailing list here:

http://lists.openstack.org/pipermail/openstack-dev/2013-September/015490.html

and discussions at summit, this patch removes the os-personalities
from the V3 API.

DocImpact

Part of blueprint v3-api-remove-extensions

Change-Id: I1a57ca812a9d71c0b1bab5d16ffad8eb82cba539
Remove traces of V3 personality extension from api samples

Removes occurences of the personality extension from the V3 API
samples as the extension has been removed. Cleanup of consistency
of image and flavor ref examples for the api samples.

DocImpact

Partially implements blueprint v3-api-remove-extensions

Change-Id: I43a34097904d3d7e280039c3d5d76479a49e92d0
Check if reboot request type is None

If the reboot request type is None, raise HTTPBadRequest like if the
argument was missing.

Change-Id: I75b1791b7a6c9304c3a78e869fe63d72302fc9d8
Closes-Bug: #1247735
fakevirt: return hypervisor_version as an int instead of a string

The compute_nodes.hypervisor_version type in the database is an integer
not a string. This is only caught in postgres and not MySQL. Changing
the fakevirt driver to return the proper type allows for the
test_virt_drivers test to make check this for all drivers it currently
tests.

Change-Id: I25e4dba855b954a2451bced9a53172b51eb47238
Fix logic in LibvirtConnTestCase._check_xml_and_uri

The _check_xml_and_uri method has two loops making it
iterate over different hypervisor types. By default it
will iterate over qemu, kvm, xen and lxc, but it can be
made to only check xen by setting the 'xen_only' param
or the 'expect_xen_hvm' parameters.

Unfortunately the second loop is only filtered if the
'expect_xen_hvm' parameter is set, not if only the
'xen_only' parameter is set. This flaw hasn't showed
up before, due to a flaw elsewhere in the libvirt
driver code, cancelling it out.

Change-Id: If70faa05975b726067ab6edaa505ca8d0c230a38
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Remove duplicate setting of os_type in libvirt config builder

In the following change

  commit 158d821204d2f79cc06c1443562b3ce9bbe7cb9f
  Author: Christoph Thiel <cthiel@suse.com>
  Date:   Thu Jul 26 00:07:24 2012 +0200

    libvirt driver: set os_type to support xen hvm/pv

The libvirt driver get_guest_config() method was changed to
use the 'vm_mode' property from the instance to set the guest
os_type attribute. If this property was not set, then it used
defaults based on the virt type. Unfortunately it neglected to
remove most of the existing later code which also set os_type
based on virt type. So in many cases we end up setting the
os_type twice. Fortunately this did not have any ill effects,
since only Xen currently needs the ability to override os_type
using 'vm_mode'. This change cleans up the mess to avoid
future confusion & problems.

Change-Id: Ib11cb1196755f993b07e892e9f2adfc36e44a4e2
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Compact pre-Icehouse database migrations <= 150.

Compacts the pre-Icehouse database migrations <= 150 into a
single migration (150_havana.py).

Pre-Icehouse users will now need to upgrade to Havana before
running any Icehouse migrations.

Tested on MySQL and PostgreSQL schemas on Fedora 19 to ensure the
new compacted migration generates an identical schema to the
previous migrate scripts in Havana.

Specific changes include:

 1) Make migrations.instance_uuid a String 36.

 2) Add migrations_instance_uuid_and_status_idx index.

 3) rename instance info caches seq (postgresql only, dropped from
    baseline)

 4) Add source_node, dest_node columns to migrations. Indexes...

 5) Add new volume usage cache table.

 6) Drop aggregates.availability_zone column.

 7) Drop services.availability_zone column.

 8) Add instance actions tables.

 9) Convert PostgreSQL to INET.

 10) Add host to instance faults.

Implements: blueprint compact-havana-db-migrations

Change-Id: Ic0c318967b69af32536b5ab6999affc7755ec442
Compact pre-Icehouse database migrations <= 160.

Compacts the pre-Icehouse database migrations <= 160 into a
single migration (160_havana.py).

Pre-Icehouse users will now need to upgrade to Havana before
running any Icehouse migrations.

Tested on MySQL and PostgreSQL schemas on Fedora 19 to ensure the
new compacted migration generates an identical schema to the
previous migrate scripts in Havana.

Specific changes include:

 1) Make task_log period_begining, period_ending a DateTime.

 2) Change type of deleted column.

 3) Create shadow tables.

 4) Add task log unique constraint.

 5) Add security_group_default_rules table.

 6) Add networks unique constraint.

 7) Revert ip column length.

NOTE: This patch removes the 184_sqlite_upgrade.sql and
184_sqlite_downgrade.sql migrations since these were causing
new test failures and the standard DB migration seems to take
care of it.

Implements: blueprint compact-havana-db-migrations

Change-Id: If977e5f02fffbfb1bc257b3beddf2d7133e6c7b9
VMware: Fix unhandled session failure issues

VMware driver has a re-try mechanism to handle session expiration
failures. Due to a minor bug in the exception handling module, this
failure was unhandled.

The patch fixes this issue and has added tests.

Closes-Bug: #1252827
Change-Id: Ie91adb4b4b57b7cefeed855cdbe4710da86294f0
Document when config options were deprecated

When going through the code and looking for what code was deprecated and
when, its easier to know if there is an explicit comment. Otherwise one
has to trace through 'git log' and 'git blame' to be 100% sure that its
ok to remove the code.

Change-Id: I57b5861e57168c44729934757e732de962f3d91a
Clean up test cases for compute.manager._check_instance_build_time

This patch cleans up the unit tests related to the
_check_instance_build_time method so that they are actually verifying
the expected vm_state value when the instance is updated.

This patch also removes the test_instance_build_timeout test case
since it was completely redundant with the other one modified
here. I checked the git history and both test cases were added
in the same commit which confirms that they weren't added for
different reasons, i.e. separate bug fixes/use cases.

Change-Id: Ib384c84e2954bd303661386256053b3c1ad38239
xenapi: stop hang during glance download

It seems there are cases when the server gets stuck in a building state
because the download from glance fails, but the nova-compute doesn't
find out.

After some code inspect, a likely cause seems to related to having no
socket timeout inside urllib2 when we download the image from glance. A
workaround for this issue is to configure the default socket timeout as
described here:
http://docs.python.org/3.1/howto/urllib2.html#sockets-and-layers

Fixes bug 1251650
Change-Id: I8b34d95d3524f3825b28e61cbbb59290653d3711
Fix HTTP response code for network APIs and improve error message

This patch corrects the http response codes for network resources to be
consistant with other resources by returning a 400 instead of a 404
if the desired resource is not found.

This patch makes the following api changes:

v2-api: NetworkNotFound now returns 400 instead of 404 and improved error
        message which network was not found instead of
        'The resource could not be found'.

v3-api: PortNotFound and NetworkNotFound now returns a 400 instead of a 404.

Closes-bug: #1245696
DocImpact

Change-Id: I66eb0c0ab926e0a8d1e2c9cfe1f7fd579ea3da21
Don't log stacktrace for UnexpectedTaskStateError

An UnexpectedTaskStateError is actually an expected behavior and we
don't need to log a stacktrace every time it happens. This stacktrace
is one of the most common ones found in nova-compute during gating jobs.

Change-Id: I8b33f72dc0f4beaca969de084481d66987faa974
Configuration element for describing video drivers.

The configuration is needed to allow the users to select
a non default video driver.

Partially implements blueprint libvirt-video-driver-selection
Change-Id: Ic6b3e44cfb7e22e0a215f7b159963df35ee1ebac
Libvirt: Adding video device to instances

Adding a video device driver to an instance, when VNC or SPICE are enabled.
Selecting the qxl driver when SPICE is enabled, otherwise use the Libvirt default, cirrus.

Implements blueprint libvirt-video-driver-selection
Change-Id: Icc3c538f2b81cc242baf87dc3538c27daf96ec38