Allow configuring the wsgi pool size

Expose the number of greenthreads in wsgi pool to configuration. This
allows to put a limit to the number of resources like memcache
connections used.

DocImpact
Change-Id: I6e53d6e12661ed2f42a6b543891b13eec0c8300c
Enforce metadata string type on key/value pairs

The compute API is currently enforcing quota limits for user metadata
and length restrictions on the dict entries, but is not enforcing that
they are string types. This patch adds the checks for string type on the
keys and values in the metadata dict.

Closes-Bug: #1240319

Change-Id: Ic4aacc342cf37d929871287e6e4917f4f48b63e8
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
Update openstack/common/periodic_task

The following commits are in this update:

1771a77 Adjust import order according to PEP8 imports rule
4bfb7a2 Apply six for metaclass
0ea069e Removed calls to locals()
1a2df89 Enable H302 hacking check

Change-Id: I5d15d9772002a2f764acef16e28bcfa16a9760c0
Clean up unused variables

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

Change-Id: I0bc9fc1474e15801e4df84f78636c96ea1f916ff
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
Fixes get_vm_storage_paths issue for Hyper-V V2 API

Add get_vm_storage_paths function to vmutilsv2.py

get_vm_storage_paths implementation on Hyper-V V2 API changed
compared to previous V1 API. In previous V1 APIs, using
Msvm_ResourceAllocationSettingData class can get storage
paths, but in V2 API, only using Msvm_StorageAllocationSettingData
class can get the storage paths.

Closes-Bug: #1248463

Change-Id: Ica73221524f162a6ffcd9dc64ee33c85fb5ad31d
Remove useless api sample template files for flavor-rxtx v3

flavor-rxtx template files flavor-get-resp.* and flavors-detail-resp.*
isn't used by any api sample test. So remove them.

Change-Id: I74760bcd5367487aca31cdf94fa5e5715f19f4c6
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
Add decorator expected_errors for flavors_extraspecs v3

This patch add decorator expected_errors and also add catching
for FlavorNotFound.

Partially implements bp nova-v3-api

DocImpact

Change-Id: I56556871f649ba56211d3f523a184e3171dd3b7e
convert min_count and max_count to type int in nova v3 api

this converts min_count and max_count to type:int in nova
v3 api.
If the string type hasn't been converted, in the method
_check_num_instances_quota of nova/compute/api.py, something
like req_ram = '2'*128 will occur. That's why the issue in
bug 1254616 arise.

Change-Id: I567b249e7a30681980ed760d5d09aad4c8e603b9
Closes-bug: 1254616
Fix a lazy-load exception in security_group_update()

When security_group_api is nova, the update_security_group api raises http
500 error: group rules fails with lazy load exception. Because the rule
infos of the security group will be return in response body, but the rule
attribute hasn't been preloaded.

Closes-Bug: #1244018
Change-Id: Ie07879ac22e4add90f75968778bf334915e8349c
Check Neutron port quota during validate_networks in API

Unless ports are passed into Nova it will create ports on the
requested networks as part of the network allocation in
the compute manager. However if the user exceeds their
port quota the instance will end up in an Error state, having
first been re-scheduled a number of times.

It would be much better if the quota failure was detected as
part of the network validation in the API server, so that an
error can be reported to the user and the creation failed.

A full fix would include reserving or creating the ports at
this stage, but there is no reservation mechanism in the
Neutron API, and port creation depends in some cases
on mac addresses only available on the compute manager.

Instead this change just validates the quota and adjusts the
max_count to be consistent with that quota, which doesn't
guarantee that the create will work, but does catch the
majority of cases.

Refs bug: 1172808

Change-Id: Iaaee059a6746fad68049712f94b2f8cfea6ab8dc
Fix LibvirtGenericVIFDriver.get_config() for quota

When Nova is used with Neutron and Open vSwitch, network quotas on the
bandwidth are ignored by libvirt: the "<bandwidth>" tag is not generated in
libvirt.xml of the virtual machine. This change fixes this issue but also for
the network types: "bridge", "network" and "direct".

Commands to create the flavor with download limited to 1 MB/sec and create a
virtual machine with this flavor:
---
nova flavor-create --ephemeral=1 victor_test_vif 50 256 1 1
nova flavor-key victor_test_vif set quota:vif_inbound_average=1000
nova boot --flavor=victor_test_vif --image=cirros-0.3.1-x86_64-uec victor_test
---

Commands to upload a file to this virtual machine with SCP to check that the
bandwidth is limited to 1 MB/sec (replace 10.0.0.3 with the IP of the virtual
machine):
---
ip netns
sudo ip netns exec qrouter-128db593-a0db-40c3-84c7-e6383d40c75f bash

dd if=/dev/urandom of=random10MB bs=1024 count=10240
scp random10M cirros@10.0.3:
---

Change-Id: I0f0111fc79fe90900e38df022034b208f1129088
Closes-Bug: #1254664
Remove unused flag 'host_state_interval'

Patch I749204d7d6461993d0c42bf5877b65c5ec17c62f removed periodic task
`_report_driver_status()`, which fanout this host's capabilities to
nova scheduler. So the flag 'host_state_interval' is not used.
Just remove it in this patch.

DocImpact: the 'host_state_interval' flag has been removed. It was last used in
grizzly and was not used in havana.

Change-Id: Ieb047ccb33cdecc6f25b6ae128dcac4e1c00cd98
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>
DB migration 209: Clean up child rows as well

Fixes bug 1252891

In order to add missing foreign key constraints, rows that reference a
nonexistant key need to be purged. Unfortunately, DB migration 209 does
not clean up any rows in child tables that themselves have a foreign key
constraint on the tables with the missing foreign keys. This can result
in an integrity violation causing the migration to fail.

When purging the rows, make sure to purge rows in any child tables first.

Change-Id: I25bd899383c72cb0670819b030759630ac89acaa
Periodic task _heal_instance_info_cache can now use slave db

This periodic task will now use a slave db for all reads if a slave
is configured. For deployments with no slave, behavior remains unchanged.

Change-Id: Iafda7ff7a895b21a75c6d3923269f45bc84c81b0
Partially-implements: blueprint periodic-tasks-to-db-slave
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