versions API: ignore request with a body

Update the OS API versions controller so it ignores requests
with a body. Previously an incoming (unauthenticated)
request to the versions API would log a TypeError trace
in the nova-api.log file with the following message:

TypeError: index() got an unexpected keyword argument 'body'

Change-Id: Icc3ccfc537b13627b8d5ba43ae3ba91e34e08c9e
Closes-bug: #1306727
VMware: prevent image snapshot if no root disk defined

If there is no root disk defined then the snapshot should
throw an exception.

Change-Id: I0549b8ca9ba41b734277600cb66a74b27ca72d88
Related-bug: #1297605
(cherry picked from commit e0638e29cda39c609ecf518e5adacf70e158d71a)
Fixes Hyper-V iSCSI target login method

Hyper-V is trying to log in to portals/targets every time a volume
is attached, even if the portal/target was already connected. This
is not an issue with most volume backends, but it causes the attach
to fail when using Storwize as a Cinder backend.

This patch fixes the issue by checking if the target or portal is
already connected, and simply perform an update in this case,
instead of attempting to create a new connection.

Also, a retry loop is introduced for the case when the iSCSI target
login fails. As in this loop it is checked whether or not the
operation completed successfully, this method does not rely anymore
only on a sleep interval to ensure that the connection to the target
has been made. Even so, on V2 volume utilities, the sleep interval
is still needed to avoid having a new connection attempt before the
last one finished.

The method which gets the according mounted disk must raise an
exception when the device number is -1, which signifies that the
disk has not been mounted properly.

Co-Authored-By: Jay Bryant <jsbryant@us.ibm.com>

Closes-bug: #1221525

Change-Id: I92d2a586704fa3e857f46432bb571c81e86d183b
(cherry picked from commit ea91ad2b2317cb88fb14c0cdaf31187eca93ff57)
Include pending task in log message on skip sync_power_state

To better understand why sync_power_state is being skipped include the
pending task name in the log message.

Change-Id: I832a3d5820efab301e12610b28ca2a1e5cfd946a
(cherry picked from commit affbbca5af2506aafb743211c901f7f0ca4e131a)
VCDriver - Ignore host in Maintenance mode in stats update

The VCDriver during stats update checks only for connected hosts.
However hosts which are in connected state to the Cluster can
be set to Maintenance mode.
The cluster does not boot instances to hosts which are in
maintenance mode.
Hence the VCDriver should check for hosts which are in
maintenance mode and ignore them for stats update.
VISDK API returns True for the property inMaintenanceMode for
Hosts which are in maintenance mode

Change-Id: Ieaf7530ed2d98c59c5450e8cb75e209823193d49
Closes-Bug: #1316674
(cherry picked from commit 4cb139fb99814f04b9e4595d7e2efa34e7992826)
libvirt: Refresh volume connection_info after volume snapshot

The following patch is related to the guest assisted snapshot
functionality.  When you take a snapshot of a volume
(e.g. GlusterFS) attached to a running instance, a new snapshot
file is created, i.e. volume-<uuid>.<snapshot-uuid>.  The
instance uses this file as the active volume.  If you shutdown
and restart the instance, nova will reattach the base volume
(volume-<uuid>) to the instance instead of the snapshot volume
(volume-<uuid>.<snapshot-uuid>).  The expected behavior is to
have the snapshot volume reattach to the instance.  This is
caused by stale data being returned from the database when
_get_instance_volume_block_device_info is called during
_power_on.  To fix this bug, this patch calls
refresh_connection_info to update the database in both
volume_snapshot_create and _volume_snapshot_delete methods of the
libvirt driver.

Conflicts:
	nova/tests/virt/libvirt/test_libvirt.py

Change-Id: I0f340a3f879580e7981d97863bc299e33d71aa84
Closes-Bug: #1304695
Neutronv2 api does not support neutron without port quota

If quota on ports are disabled in neutron (see below), neutronv2 api
set port quota to None and quota check raises a TypeError.

  # neutron server /etc/neutron/neutron.conf
  [quotas]
  quota_items=network,subnet,router,floatingip

This change set port quota to -1 (unlimited) if quota on ports are
disabled.

Change-Id: I89c530dd57a7beb35695be124ca8511148378458
Closes-Bug: #1333315
(cherry picked from commit 04add2ed0d8b0341ea347ac98834f75cf5b2be1d)
Fix security group list when not defined for an instance

If an instance has an empty security group list an exception
is thrown due to iteration attempt of None.

To fix this, this patch modifies get_instance_security_group
to return an empty list instead of None.

Change-Id: I7efb3c3a58d7e20501d126c6d194479ca1d14166
Closes-Bug: #1291489
(cherry picked from commit c32986966dfd034c3d706b2e9ab2820a2c3cfc3e)
Updated from global requirements

Change-Id: If1677541081467bb464b0fd265ce4340a67d8862
Attach/detach interface to paused instance with affect live flag

Currently attach/detach interface to paused instance is only with
VIR_DOMAIN_AFFECT_CONFIG flags. After instance unpause, there isn't
any effect on the instance, unless restart the instance. So add
flag VIR_DOMAIN_AFFECT_LIVE when attach/detach interface.

Conflicts:
	nova/tests/virt/libvirt/test_libvirt.py

Change-Id: Iedfc7f6fc06e72d8e3eecebede1274582c8043fd
Closes-Bug: #1299331
(cherry picked from commit a868fcedf8e46070cae6aa8e59e61934fa23db1c)
Do not process events for instances without host

In some cases Neutron might send events such as 'VIF unplugged'
for instances which are either being deleted or shelved. When
that happens there will be a failure in dispatching the event
to the appropriate compute node - as there is no host for the
instance.

As multiple neutron events can be stashed in a single call
it is important to avoid that this kind of errors will prevent
processing of other events in the same call.

This patch does not process events for instances without a host,
marking them as failed.

When the above condition occurs, the create event request will
return a 207 response code. For specific events, a 422
unprocessable entity code will be set.

This patch also preserve the characteristic that events are
returned in the response in the same order they were found in
the request.

Change-Id: I18062b81e50c722ec96b4296ac39384493683ae3
Closes-Bug: #1333654
(cherry picked from commit 4f8ccd7b95c27180a1cfe689e3c6f46bde5f803b)
Do not pass instances without host to compute API

Even if the server external events extension filters out events
whose related instance does not have a host, the corresponding
instance is still sent to the compute API module.
As this might result in KeyError, instance without host should
be filtered out before calling the compute API module.

Change-Id: If5229ec3059076dbc9f4abb6625504e8864c265e
Closes-Bug: #1348584
(cherry picked from commit 5e4a5f0d8c62ca6e94ae6db16e9fbe0428805158)
Set python hash seed to 0 in tox.ini

New tox (>=1.7.0) sets a random python hash seed by default. This is
generally good for testing because it will help keep projects working
regardless of the hash seed, but nova unittests don't currently pass
with a random hash seed so set it to the python default seed.

This change will allow us to use new tox again and remove the
restriction on tox<=1.6.1 to run unittests.

Redundant setenvs for specific test envs are removed to prevent them
from overriding the PYTHONHASHSEED value.

Note this change will need to be backported to the stable branches to
keep unittests there working with new tox as well.

Change-Id: Ib54364877a251db48c54dfdc43c503281ea1f04a
(cherry picked from commit 4f3e3cd1883ea5aca237bcc88b64128c743a6862)
Merge "Set python hash seed to 0 in tox.ini" into stable/icehouse
VMware: use default values in get_info() when properties are missing

The properties that we retrieve from VirtualMachineConfigSummary are
optional ('summary.config.numCpu', 'summary.config.memorySizeMB') and
if they are missing we should return default values from get_info()

This patch also improves the unit test for get_info(). It removes the
test in test_driver_api.py (test_get_info() and test_spawn() are the
same) and adds a new test in test_vmops.py

Conflicts:

	nova/tests/virt/vmwareapi/test_driver_api.py
	nova/tests/virt/vmwareapi/test_vmops.py

Closes-Bug: 1317912
Change-Id: Ibbb28985d13de371fdac8a119ad820d25acc21be
(cherry picked from commit 2db7528ca258d7b0c1205ab2f9a76569d9f9a82d)
Merge "VCDriver - Ignore host in Maintenance mode in stats update" into stable/icehouse
Merge "Updated from global requirements" into stable/icehouse
Merge "Fixes Hyper-V iSCSI target login method" into stable/icehouse
Merge "libvirt: Refresh volume connection_info after volume snapshot" into stable/icehouse
Merge "versions API: ignore request with a body" into stable/icehouse