Adds IVS unit tests for new VIF firewall logic

Adds new unit tests for the IVS VIF driver to
cover the various possible plugging behaviors
added by the vif_details based logic introduced
in change I3bbcfc67036ab7389c82720add0bc0fc627bfee0.

Closes-Bug: #1301087
Change-Id: I7f0a1460b948a852c2d61d24217bbf27a4d85859
Ensure changes to api.QUOTA_SYNC_FUNCTIONS are restored.

Add a local callable restore_sync_functions() that is
established as an addCleanup() fixture callable,
making use of a copy of the QUOTA_SYNC_FUNCTIONS
dictionary to restore its previous contents in-place.

Change-Id: I7fa69ea91e517121aba0ee22a71b0594591ae308
Closes-Bug: #1329482
libvirt: Use VIR_DOMAIN_AFFECT_LIVE for paused instances

When a volume is attached to a paused instance, it does not
appear in the instance's block devices list (i.e. lsblk)
after the instance has resumed. A similar situation
happens when detaching a volume from a paused instance; the
block device continues to exists in the block devices list,
where it should not.  It was found that the volume is only
persisted in the domain's config settings and not its active
settings, since only the VIR_DOMAIN_AFFECT_CONFIG flag was used
on attach and detach volume.  In order to affect the active
settings, the VIR_DOMAIN_AFFECT_LIVE flag has to be added when
attaching and detaching volumes.

Change-Id: I9c90a410a7ecb91f5a4de28acee21fe7da49242c
Closes-Bug: #1242366
Related-Bug: #1299331
Downgrade log level when create network failed

We raised exception when create network failed because of exceed
quota, downgrade to debug level for those exceptions because
LOG.exception will generate a stacktrace.

Change-Id: I22446f08ee078c624970f233875874a67ea423b9
Catch ProcessExecutionError in revoke_cert

Catch processExecutionError if revoking the
certificate fails.

This change has been abandoned by Chuck Short, so
I am continuing where he left off (mattoliverau).

Continues abandoned change: 17741

Change-Id: I9714ea8cece87256ff5f9a936286c1da3d628af9
Closes-Bug: #883320
Co-Authored-By: chuck.short@canonical.com
Add missing stats info to BaremetalNodeState

This is the first of two patches to prepare baremetal for the removal
of capabilities in Nova HostManager.

BaremetalHostManager used to rely on capabilities info to decide which
host state class to use, VM or baremetal. This has been broken since
host capabilities reporting were removed in Nova, resulting in Nova
HostState class always being used.

BaremetalNodeState lacks stats info needed by some filters during
scheduling. This may result in failures like ComputeCapabilitiesFilter
not returning any hosts. This must be fixed before BaremetalNodeState
can be used again.

Change-Id: I63d992371640b2fd33d35eae72201fd41944f8a4
Partial-Bug: #1260265
XenAPI: disable/enable host will be failed when using XenServer

When disable/enable host with XenServer, the api of set_host_enabled()
in XenServer driver needs to get service info for the target host, but
the rpc call of set_host_enabled() did not transfer target host as
parameter, this will cause the api call failed.

This patch was let the API of set_host_enabled() use CONF.host.

Closes-Bug: #1251943

Change-Id: I2b6427df80ee3188d6f7c4eeb4d2e7be300f0126
Drop support for conductor 1.x rpc interface

In commit 330ce897c14f66a39426e716f02a620453035c15, a part of
Icehouse, we added support for the 2.x interface.  Now that Juno
development is open, we can drop support for the old API, 1.x.

For more information on this change, see:

    https://wiki.openstack.org/wiki/RpcMajorVersionUpdates

UpgradeImpact

Change-Id: Id7e605d493a53eaaa2a9afa0c99ac721f590ca3f
Drop support for scheduler 2.x rpc interface

In commit 741661a6695ccc56e5f50c4d85954cd3ed9ebda5, a part of
Icehouse, we added support for the 3.x interface.  Now that Juno
development is open, we can drop support for the old 2.x API.

For more information on this change, see:

    https://wiki.openstack.org/wiki/RpcMajorVersionUpdates

UpgradeImpact

Change-Id: I7bfad51ae46e999b30e003a5a5c7e341461dba02
Don't store duplicate policies for server_group

It doesn't make sense to store same policies in a server_group.
We need to deny this usage in server_group creation.

Change-Id: I4f3ad544aef78cbbc076c7a47cca04832a2f5b4b
Closes-Bug: #1324348
Should not delete active snapshot when instance is terminated

The instance might be deleted when doing snapshot, need to check
whether the snapshot is active state before delete it.

Change-Id: Ic12b8dfd05ad7f36831dd073cef746f094d8f2d0
Closes-Bug: #1329882
Set reasonable defaults for new network values

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: Ic9c60071480abc5fced04dab5fc79ea44db1e10d
Determine shared ip from table instead of flag

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: Id7c6620704fef504d23cb42c5218251fa9e2dba7
Instance and volume cleanup when a build fails

On failed builds the _shutdown_instance method used to get called which
would clean up leftover instance artifacts, volume attachments, and
networking.  This no longer happens which is causing volumes to be left
in an attached state when they're not attached to anything.

Network deallocation is already handled in this code path so it should
not happen in _shutdown_instance.

Change-Id: I899b64ac5941acc282ccae7e1963d6f714c01e8b
Closes-bug: #1332198
VMware: remove unused code in vm_util.py

Remove a few functions not used anymore and not tested. This increases
the code coverage and decreases the time devs scrolls through the file.

Change-Id: I8398bceb8771d9c180bcd6cbafbf1f3e839f9307
Allow evacuate from vm_state=Error

We currently allow reboot/rebuild/rescue for an instance in the Error state.
This commit allows "evacuate" as well, since it is essentially a "rebuild"
on a different compute node.

This is useful in a number of cases, in particular if an initial evacuation
attempt fails.

Change-Id: I3f513eb738c91fe71767308f57251629639efd6a
Closes-Bug: 1298061
Catch permission denied exception when update host

When an existing non-openstack instance in the compute node contains
disk file which can not be accessed by nova non-root user, resources can
not be updated successfully when periodic task is running. Also the
nova-compute service could not be restared again. We should catch such
exception.

Change-Id: I75195417e123f135252470cf1322843830556b0a
Closes-Bug: 1322467
Target host in evacuate can't be the original one

'Evacuate' function aims to help administrator/operator to evacuate
servers if this compute node fails.

If no protection, the API returns a successful response,
but the vm_state will be changed to ERROR after nova-compute started,
due to the 'InstanceExists' exception raised from 'rebuild_instance()'.

So we need to add verification here, the target host should not be the
original host.

Change-Id: Ic468cd57688b370a18cacfc6e0844a8201eb9ab3
Closes-Bug: #1271821
Correct the variable name in trusted filter

Rename instance to instance_type to avoid misunderstanding

Change-Id: I88f8d31074d7547649c242a023b18143a0092fea
Don't follow HTTP_PROXY when talking to localhost test server

Unlike urllib2, requests honours HTTP_PROXY by default.  This meant
test_uri_length_limit's test queries to http://localhost:$port/ would
hit the wrong localhost when $HTTP_PROXY was another host - resulting in a
meaningless test scenario and apparent failures with HTTP status codes
other than the expected REQUEST_URI_TOO_LARGE (414).

This change forces requests to go direct for those test queries.

Closes-Bug: #1329614
Change-Id: Ida3424ca9a750bd2d3f2e81dc7dfacc2a334adf1