Test for remote directory creation before shutting down instance

This patch moves the creation of the directory on the migration target
earlier in the code path so we can catch failures like missing or incorrect
keypairs on the source and destination node.

This fixes part of bug #1061024 but not all of it yet.

Change-Id: I097cf007cdd8de0c9c3a9390cbc6dc202eddb2b5
Fixes encoding issues for nova api req body.

* Ensure utf-8 encoding for POST/PUT body for api requests
* As per https://wiki.openstack.org/wiki/Encoding.

Fixes bug #1180344

Change-Id: Iea0f16b0c024795fb3aee1cd38bb54ee9da6d90d
Fix missing argument to logging warning call

Change-Id: I04ff613e785b6b39476b7766b94c831d7e22148a
Optimize SecurityGroupsOutputController by len(servers)

The following patch adds an optimization for _extend_servers() so that
it calls get_instance_security_groups() when len(servers) == 1, and
get_instances_security_groups_bindings() when > 1. In addition, this patch
adds a return statement if not len(servers) as there is no reason to
perform a query if there are no servers.

Fixes bug 1182730

Change-Id: I149bf32176d60e72d76576168d15995f7215b657
Add missing tests for nova.db.api.agent_build_* methods

blueprint db-api-tests

Change-Id: If8f8a3f02bc0ea73b9174caad60107c7d87f62c0
Raise AgentBuildNotFound on updating/destroying deleted object

Methods below should raise an exception when attempting to operate
with deleted AgentBuild objects:

 nova.db.sqlalchemy.api.agent_build_destroy()
 nova.db.sqlalchemy.api.agent_build_update()

Fixes: bug 1181967

Change-Id: If6df202afb7ea41634c35f7a52988e19677f4d65
Using unicode() to handle image's properties

Replace str() to unicode() to allow nova-api work well with the fix I
did in glanceclient (https://review.openstack.org/#/c/29245/6).

Fixes: Bug #1180377

Change-Id: I31e532bb50e12e355b9dd26c9ce1e129da858cbe
Signed-off-by: Zhi Yan Liu <lzy.dev@gmail.com>
Remove path_exists from NFS/GlusterFS drivers

mkdir -p will not throw an error if the path already exists,
so this method is unneeded in these classes.

Change-Id: I65a67cb75f83f65a6f80c7a90f77c2c5133bd41b
Delete a quota through admin api.

Added 'extended-quotas' extension that has provides ability for admins
to be able to delete a non-default quota (absolute limit) for a tenant,
so that tenant's quota will revert back to the configured default.

Implements blueprint admin-api-for-delete-quota
Change-Id: I7375420a466823b3e099aebff71a8f7d7f922afb
update mailmap

Reflect new email address that I will be committing under.

Change-Id: I7358c5c8e47b4c77c8d885fe30f79c757ca943b2
Add missing tests for db.api.reservation_*

blueprint db-api-tests

Change-Id: Id191363e00f51d2c8ae0f2bac6a9c6672dfbdd65
Fix log message.

Fix a missing key in the log format.

Change-Id: I275f5e5fbfb6465b39d9ed7b4a9ace045ded4b5d
Add node as instance attribute for notification

Fix bug 1181900

In havana release, node is not set as instance attribute and node
indicates the hypervisor where the instance reside in, we should
set node as instance attribute for notification.

Change-Id: I872fba626ef3e321d88cf60fc730df6cf4612c86
Fix config drive code logical error.

Image id has changed to uuid, so bool value can't be a image ID
any more, remove unnecessary test code.

fix bug #1181991

Change-Id: I420e4cdb848401375b347d43e06343efaa7bf5fc
xenapi: make the xenapi agent optional per image

This adds the ability to decide, per image, if xenapi should use
the agent for servers created from that image.
This opens up the path to using config drive or the metadata
service with cloud-init to perform tasks like file injection

It uses the image properties that are copied into system metadata
to detect if "xenapi_agent_present"="true" on the image the server
was created from.
If the tag is not present, it defaults to the value
of the new conf setting "xenapi_agent_present_default".

Becuase the above setting defaults to False, it means that
the xenapi driver no longer waits for the agent by default.

DocImpact
fixes bug 1178223
part of blueprint xenapi-guest-agent-cloud-init-interop
Change-Id: Ie51a9f54e5b2e85fe4ebebb0aff975db296ba996
fix a misleading docstring

GroupAntiAffinityFilter was introduced to filter a set of hosts,
howerver the docstring saying filter a set of instances which need to be
fixed.

Change-Id: Icf66a3ad15b4135c06e2e2ccc62837a346fcfdf7
API Extensions framework for v3 API Part 2

This is the second patch for the new extension framework
which is only to be used by the Nova v3 API.

- Adds tracking of extensions loaded and allows
  extensions access to this information
- Adds core API functionality as extensions
  - 'server'
    - Adds an entry point that other extensions can
      use to modify the server create arguments without
      having to modify the server extension itself
    - TODO: Will have to add more entry points as other
      extensions are ported. Delaying adding entry points
      now so they can be tested as they are added.
- Adds port of os-keypairs extension
  - This is an example of a controller extension in the new
    framework
  - This is an example of using the server extension entry
    point to add functionality without modify the core API code
  - Ports tests for the os-keypairs extensions
    - Adds v3 API fake specific code for tests

This completes the bulk of the new extension framework. Porting
of the server tests will be done in future changesets as more
of the core API is ported across as the tests are dependent
on multiple core APIs.

Partially implements blueprint v3-api-extension-framework

Change-Id: Ibadb5bbe808c27d2f4afebe65c06a92576397085
Cells: Add filtering and weight support

This adds filtering and weighing support to the cells scheduler.

Adds the following config options to the 'cells' group:

scheduler_filter_classes -- list of filter classes
scheduler_weight_classes -- list of weight classes

Adds a couple of weighing modules as defaults (which removes the random
cell selection):

ram_by_instance_type: Select cells with the most capacity for the
instance type being requested.
weight_offset: Allows modifying the DB to weight a particular cell
(useful for disabling a cell)

Adds a filter class (TargetCellFilter) that allows specifying a scheduler
hint to direct a build to a particular cell if you're an admin.

DocImpact

Implements blueprint cells-filter-scheduler

Change-Id: I027c5734e3d6134127fcd4dd28b8ff39047416dc
No relevant message when stop a stopped VM

When user tries to stop a stopped VM, there is no need to stop it again,
and We need return it's vm_state.

Fixes bug 1181934

Change-Id: I71772dfcead440cb49b6ccdbb4e1a891475bb75e
Enable flake8 E721

We already pass the test, so just remove from ignore list

Change-Id: I28bfeb99d9841532133a3825f7336e7b712d6561