Change unit test for availability_zones.reset_cache

Test_rest_availability_zone_reset_cache can not make sense
because the result of az._get_cache().get('cache') before
executing az.reset_cache() and after az.reset_cache() are
same.

This Patch will provide a reasonable test for it.

Change-Id: I7a27998bdf70f39077a5d79fc460974fc5806c3e
Closes-bug: #1258041
Set a sane default for state_path

This change sets a sane default to state_path and puts the previous
state_path for tests only.

Because the default value of state_path changed, if this one isn't set in the
configuration file, pybasedir is not more used as replacement but /var/lib/nova
is used instead.

UpgradeImpact
DocImpact
Closes bug: #1240879

Change-Id: I94502bcfac8b372271acd0dbc1710c0e3009b8e1
fix log message in APIRouter

In _setup_ext_routes(...) and _setup_extensions(...)[0], there are three
logs telling that I'm setuping extensions routes, and these are done,
those failed. At line3 in [0], every resource woulld be logged before
the line 6-7 skip (conintue in Python). So here should be that I'm
'extending' resource, not 'extended'. Similiar in line 38 and line 43,
these two should be what is done and what is failed.

So this patch fix the first log from 'Extended' to 'Entending', and in
third log, 'extending' to 'extended' instend which makes context log
more reasonable.

[0] http://paste.openstack.org/show/60246/

Change-Id: I2de66f1a8e09945e1915b61771a55af6b630369c
Remove unused code in test_attach_interfaces.py

"body = jsonutils.dumps({'port_id': FAKE_PORT_ID1})" is unused in
test_attach_interface_without_network_id(). We should remove it.

Change-Id: Id31b559752d57c9f55fd2bf0de909b8d8f9a0333
Closes-Bug: #1266617
Make image props filter handle old vm_modes

The ImagePropertyFilter would fail to build an instance if the image
used an older style vm_mode (e.g. 'pv') as described in
nova.compute.vm_mode.  This change will convert the vm mode string to
the current form.

Change-Id: Ibde37e28b02d9e866b286ea14c47a6a8411d94b4
Closes-Bug: #1276773
Merge same db calls for some quota methods

db.quota_get_all_by_project is called twice in method limit_check()
and reserve(),
db.quota_get_all_by_project_and_user is called twice in method
get_settable_quotas() in nova/quota.py

Change-Id: Ie5e3a414d3d52964c16613f44fe60a7f68bc0c66
Closes-bug: 1277068
Fix multi availability zone issue part 2

In order to keep consistency with fixing in
code review:
I788782a9f21ec2672551f75123753175bb268586

adding aggregate az checking logic to guarantee
that aggregate updating and aggregate metadata
updating shouldn't be done when aggregate's hosts
belong to other az. So, when az conflict exist,
user should remove those hosts.

sync the changes into V3 aggregate APIs.

Fixes: bug #1200479
Change-Id: I18ad1ac22c6aee298ccc75c978b85241ae1ac616
VMware: Fix incorrect comment indentation

Change-Id: I60ae70701af2506753ded5ef3d25f17cc36a0b1b
VMware: improve exception logging in driver.py

Change-Id: Id46860d269462673bc935653b2ce1ea1036db002
Make floating_ip_bulk_destroy deallocate quota if not auto_assigned

The expected use case for floating_ip_bulk_destroy is to destroy
auto_assigned floating IPs, for which no quota is used so no quota
needs to be recovered.  But it can also be used to destroy other
(not auto_assigned) floating IPs, in which case the previously used
quota was not recovered.  This fixes the quota leak in that unusual
case.

Closes-Bug: #1254174

Change-Id: Ibff80d9ebac8d4422e401909033da12d9ec0b593
Correct host managers free disk calculation

Take lower of disk_least_available/free_disk_gb if they exist.

When an instance exists in the database but not on the hypervisor
(which can happen in some error cases), the 'missing' instance
is included in the calculation of 'free_gb' but not included in
'disk_available_least'.
Need to take the value that represents the minimum amount of free
disk space available.

Testing:
COMPUTE_NODES in fakes.py includes the 4 possible test cases:
    disk_least_available or free_disk_gb = free_disk_mb
        None             or     512      =    524288
        1024             or    None      =   1048576
        3333             or    3072      =   3145728
        8192             or    8888      =   8388608
   test: test_host_manager.py
           test_get_all_host_states:
             Already has existing tests looking for these
             cases - I've modifed the test data (in fakes.py)
             rather than creating new test data.
             Added check for Warning message for node 3 where
             physical disk (3333) is greater than database (3072)
         No impact on other tests.

Change-Id: I4a18bf023a64d0cb198f77aab9daecb0786e93ff
Closes-Bug: 1253599
Remove flavor-disabled related policy rules for v3 api

flavor-disabled extension have already merged into flavors core.
This patch removes those useless policy rules.

Change-Id: Ief2a96710cdfaee89c1864a8474b9db6d4b02cd5
Remove policy check in db layer for aggregates

Since there already are policy checks in v2 and v3 api layer,
no need to check again at db layer. This patch remove
that check for aggregates. Also added policy test
on api layer for v2 API(v3 already have),
removed 2 test cases in db layer focused admin context.

Change-Id: Ied1fd109be104a9539d1cad7937455852e20ffb2
Implements: blueprint v3-api-policy
Update policy check on each action for certificates

v3 api requested policy check on each action instead of the whole
topic, this patch update the check in certificates and add test cases
for v3 certificates api policy

Change-Id: I9433188beb1e085bc66fc013a285ca2c32fd08f7
Implements: blueprint v3-api-policy
Do not set root device for libvirt+Xen

Currently we are setting the root device for Xen when using libvirt.
When a user is booting an image that contains a full partitioned disk it
fails, since the root device will be passed as "root=/dev/whatever" as
the cmdline to the booting kernel.

Closes-Bug: 1253626
Change-Id: Ia5e3ee8891759c68ee51b219d1a7f80d0afbeffc
Remove unused methods

The following methods are not used.
 o name() in nova/compute/power_state.py
    name() has been deleted in the following commit.

      commit 5270b0a565ec26d2f7de3a7d95be86433d8c6bd2
      Author: Dan Prince <dan.prince@rackspace.com>
      Date:   Wed Aug 17 11:46:28 2011 -0400

          Split set state into vm, task, and power state functions.

 o valid_states() in nova/compute/power_state.py
    valid_states() has been deleted in the following commit.

      commit 84e069b8d637c08f0434038ff2a2b272254e4a0e
      Author: Dan Prince <dprince@redhat.com>
      Date:   Mon Aug 6 12:09:23 2012 -0400

          Remove unused InstanceInfo class.

Change-Id: I85051d27834f166d5a3596e31ea4f78b82809fda
XenAPI: Wait for VDI on introduce

Some SRs, particularly iSCSI connections, are slow to see the VDIs.

Introduce a sleep when a VDI that we're definitely expecting is not
present on the SR.

Change-Id: I7c71f1c7b811603aeacbb34c913dc236bba2132a
Closes-bug: 1274088
Make os-service API return correct error messages

webob.exc.HTTPBadRequest() can't return the error message
by passing 'detail' parameter.
This patch fixes this bug in nova service_update.

Change-Id: I889d7d1caddd1f0b0dc63292c3ceac7e493b6b79
Make nova-network use FixedIP for host and instance queries

This makes nova-network manager use the FixedIP object for the
get_by_network_and_host() and get_by_instance_uuid() queries.

Related to blueprint nova-network-objects

Change-Id: Ifa26ba1db6a9975e21a5a1c4b8742d82ca6d0772
Make nova-network use FixedIP object for vif queries and bulk create

This makes nova-network use FixedIP for querying by virtual interface
and for bulk-creating IP records in the database. These two unrelated
changes were both smallish and thus combined into this patch to
reduce the queue depth for this series.

Related to blueprint nova-network-objects

Change-Id: I93d6ce32b0960173d70f6ec32d889ae91e2849bb