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
Added validation for networks parameter value

A validation check is added for networks parameter value.
In server create request body, if networks parameter value
is not stored in a list then 'Bad networks format' error
is thrown with bad request exception.A new test case is
added to verify whether it is returning bad request exception
when invalid syntax is used.

Fixes: bug #1175683

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

Change-Id: I04ff613e785b6b39476b7766b94c831d7e22148a
Disallow resize if image not available

If a resize is attempted on an instance that was started from an image
that has since been deleted, a resize will fail. This change makes error
reporting a bit cleaner.

This change is needed since in order to actually properly support
resize/migrate when the image is deleted - it is necessary for nova to keep
a copy of the image metadata and re-use it in case of migration/resize.

Fixes bug: 1160773
Fixes bug: 1177001

Change-Id: Ifaea71f79c97046a4cde094e3a5e676772fcceb4
get_instance_security_groups() fails if no name on security group

The following patch fixes a bug in get_instance_security_groups() where
it tries to access security_groups['id'] but security_groups is a string.
This patch also removes some stubs that were not needed in a few unit test.

Fixes bug 1182738

Change-Id: Ia64db2e40d4a0e163344b4234112dbde71b1e132
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
Removed session from fixed_ip_*() functions.

Removed session objects from public fixed_ip_*() functions
in nova/db/sqlalchemy/api module. Minor code refactiring.

blueprint db-session-cleanup

Change-Id: Ic2a96270745799496e365aee0380ac079e1edeff
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
Share checks between create and rebuild

DRYs up the checks between create and rebuild in preparation for additional
checks going in.

Change-Id: I04a8448f7a3a4e1176b40f943ea9c90c06ba8ece
Move ImageTooLarge check to Compute API

The existing ImageTooLarge check is in the compute manager, meaning that a
validation error puts the instance into an ERROR state without the ability to
communicate the fault back to the user.

This patch moves the check to the API where we can return the appropriate
error to the user.

Change-Id: I2183449351e3b70f98d0552ea247184a3641d85a
Remove ImageTooLarge exception

InstanceTypeDiskTooSmall and ImageTooLarge are really two sides of the same
coin; an image is larger than the root_gb of the instance_type. Rather than
have two exceptions for this, this patch consolidates down to just
InstanceTypeDiskTooSmall.

Change-Id: I401205072c111a960beb2932c6c1889141ae03c3
xenapi: Disable VDI size check when root_gb=0

Nova uses root_gb=0 to indicate that we should use the image as-is without
trying to resize the root disk. Currently the xenapi virt-driver doesn't
properly implement this behavior.

This patch gets us a step closer by disabling the VDI size check when
root_gb=0. We still need to ensure that the disk-resize code handle root_gb=0
as well.

References bug 1155113

Change-Id: If91963e079e197a1315c48b8643f3419b42b0b2c
xenapi: Moving tests under tests/virt/xenapi/

We have both a tests/xenapi/ and a tests/virt/xenapi/ directory which
is confusing. This patch standardizes on tests/virt/xenapi/ which
matches the nova/ directory layout.

Change-Id: I324a4730e2477aa1863b17c7ea404ce2932a681c
Reset task_state when resetting vm_state to ACTIVE

A virt driver can raise InstanceFaultRollback to indicate that the
instance should be reset to ACTIVE.  However, the code that resets to
ACTIVE does not reset task_state to None.

This patch fixes that.  Technically, there's currently no bug here,
because the compute manager methods that matter here all have the
reverts_task_state() decorator to always reset task_state to None on
exceptions.  However, a bug would be introduced later if we remove
those decorators.

Change-Id: Ibcf8ae3473f601781d8aae80f88df3da54bbaac8
Rename requires files to standard names.

Rename tools/pip-requires to requirements.txt and tools/test-requires
to test-requirements.txt. These are standard files, and tools in the
general world are growing intelligence about them.

Change-Id: I68ece8406fb1d4e082a42db8e76e17b1aaa7e775
Fixes: bug #1179008
Remove locals() from scheduler filters

Just removed locals() and replaced it with an explicit dicionary.

Change-Id: Id476a684abde36238b5abfe8ce4c3ddb0874423b
Make a few places tolerant of sys_meta being a dict

This will be necessary as we start to introduce objects with
real dicts in system_metadata. These are the common spots that
need to be ready ahead of time. The rest are at the actual use
sites and can/will be replaced when individual uses are
converted to objects.

Related to bp/unified-internal-objects

Change-Id: I8314e0d52ec2ae800765f60ce58ce9b309d7d513
Merge "Removed session from fixed_ip_*() functions."
Importing correlation_id middleware from oslo-incubator

Including 'correlation_id' middleware from oslo-incubator.
Adding this to openstack-common.conf to copy over the middleware to
the location nova/openstack/common/middleware

Change-Id: I21b27e8dae585345d03d59c125d9e1bbea95f830
Implements: blueprint cross-service-request-id
Remove locals() usage from nova.virt.libvirt.volume.

Change-Id: Idda3c0c447bd1f6394805cd6230a32dc22bb6268