Send 'create volume from snapshot' to the proper host

A simple solution for bug 1008866. When creating volume from snapshot on
multicluster, in volume it will check if snapshot_id is set. If snapshot_id
is set and FLAGS.snapshot_same_host is true, make the call create volume
directly to the volume host where the snapshot resides instead of passing it
through the scheduler. So snapshot can be copy to new volume. The same as
review 9761.

Change-Id: Ic182eb4563b9462704c5969d5116629442df316a
Migrate a notifier patch from common:

commit c767e9beffe4b826eac869ce7e2eef2cc1499bbe
Author: Andrew Bogott <abogott@wikimedia.org>
Date: Thu Jul 19 03:34:31 2012 -0500

Add multiple-driver support to the notifier api.

Move all of the functionality previously provided by the list_notifier
into the basic notifier api. Move and restructure tests accordingly.

Remove the list_notifier file and test file.

For bug 1025820

Change-Id: Icadaafe8bc312942249272873d9a4a8f1aa49a94
maint: remove an unused import in libvirt.driver

This import was recently reintroduced, due to
confusing pylint output. Therefore remove it again
and adjust things so pylint won't warn in future.

Change-Id: I25f293f171c651c25d27e8d55c9240fd808590ba
Fix traceback when detaching volumes via EC2

When detaching a volume from an instance it results
in the following traceback:

Cinderclient connection created using URL: http://192.168.1.103:8776/v1/bc02ec05c5fa4a5bb3020b617f3574e2
2012-08-06 18:58:32 ERROR nova.api.ec2 [req-1fd2f017-8a11-481f-b901-ae61d3f55c94 demo demo] Unexpected error raised: 'instance_uuid'
2012-08-06 18:58:32 TRACE nova.api.ec2 Traceback (most recent call last):
2012-08-06 18:58:32 TRACE nova.api.ec2   File "/opt/stack/nova/nova/api/ec2/__init__.py", line 474, in __call__
2012-08-06 18:58:32 TRACE nova.api.ec2     result = api_request.invoke(context)
2012-08-06 18:58:32 TRACE nova.api.ec2   File "/opt/stack/nova/nova/api/ec2/apirequest.py", line 81, in invoke
2012-08-06 18:58:32 TRACE nova.api.ec2     result = method(context, **args)
2012-08-06 18:58:32 TRACE nova.api.ec2   File "/opt/stack/nova/nova/api/ec2/cloud.py", line 799, in detach_volume
2012-08-06 18:58:32 TRACE nova.api.ec2     self.compute_api.detach_volume(context,volume_id=volume_id)
2012-08-06 18:58:32 TRACE nova.api.ec2   File "/opt/stack/nova/nova/compute/api.py", line 1642, in detach_volume
2012-08-06 18:58:32 TRACE nova.api.ec2     instance_uuid = volume['instance_uuid']
2012-08-06 18:58:32 TRACE nova.api.ec2 KeyError: 'instance_uuid'

By the time the volume in the cinder database the instance_uuid is already 'NULL',
so get the instance_uuid from the volume before its detached.

Fixes LP: #1033713

Change-Id: Id5515881b08af9d0832b4b620c03e471fdff0823
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Added updated locations for iscsiadm

Attaching volumes to instances currently result in a
traceback running on 12.10.

This is due to the change of location from /sbin to
/usr/bin for iscsiadm.

Fixes LP: #1033960

Change-Id: Ie8c6214efbac72b2715264a7d9dd7fe5e43ef693
Signed-off-by: Chuck Short <chuck.short@canonical.com>
General host aggregates part 2

Partially implements blueprint general-host-aggregates: Scheduler Filter
* Add AggregateInstanceExtraSpecsFilter
* change db.aggregate_get_by_host to return a list of aggregates
  instead of the first aggregate
* Add optional key filter to db.aggregate_get_by_host along with test
* Add db.aggregate_metadata_get_by_host to get host aggregate metadata
* add optional key filter to db.aggregate_metadata_get_by_host
* Add AggregateTypeAffinityFilter

Change-Id: I4a3061276cc3b0c5c695eaf973b773183b3c4f4b
Fix invalid exception format strings

Some exception formation strings were missing the conversion type

Change-Id: I99fda0a49acce8c5c1f1b9a09bcaff24140aaf44
xenapi: wait for agent resetnetwork response

Unlike every other agent command, the resetnetwork command would not
wait for a response. All failures were silently ignored. Change this
to at least log a message if an error occurs.

Change-Id: I40e323607b2ce50869f3bf11e4582ff83cbed1c0
xenapi: reduce polling interval for agent

Communicating with the agent requires polling for a response. The
operation uses xenstore, which is lightweight, yet the interval
in between polls was 3 seconds. This would cause longer than necessary
sleeps when an instance was booting making the overall boot slower.

Change-Id: I560c05887128f1a0e29228e859cca25ded4eceec
Make libvirt_use_virtio_for_bridges flag works for all drivers.

Both LibvirtOpenVswitchDriver and QuantumLinuxBridgeVIFDriver
can use virtio driver when flag libvirt_use_virtio_for_bridges
is set.

fix bug lp:1034216

Change-Id: I5675f14845bf059651f45cfb06ae496d413fa69b
Fix a bug on db.instance_get_by_uuid in compute/manager.py

The parameter for db.instance_get_by_uuid() is instance_uuid instead of instance.
Correct it in the code.

Change-Id: Ibc4d8352c101dc3be11a765646d4ef701e330b50
Signed-off-by: Shane Wang <shane.wang@intel.com>
Merge "Fix a bug on db.instance_get_by_uuid in compute/manager.py"
Merge "xenapi: wait for agent resetnetwork response"
Fix a bug on remove_volume_connection in compute/manager.py

The function remove_volume_connection() has been changed.
Fix up the code to call the correct interface.

Change-Id: Ib0aa864d9efabb1102193a36ec05c3a1673091b5
Signed-off-by: Shane Wang <shane.wang@intel.com>
Merge "Fix a bug on remove_volume_connection in compute/manager.py"
Merge "Make libvirt_use_virtio_for_bridges flag works for all drivers."
Merge "Migrate a notifier patch from common:"
Merge "Added updated locations for iscsiadm"
Add a 50 char git title limit test to hacking.

* add N802 to hacking.py

Change-Id: I8262531b4b3f8f3a1a2a37679904cf4864cae7b6
scheduler prep_resize should not update instance['host']

This is done by the manager once things are ready on the destination
compute node.

Fixes bug 1034593

Also removes now-unneeded update_db argument passed via rpcapi and bumps
scheduler rpcapi version for prep_resize to 1.4

Change-Id: I0ac3be39877f3afcf42f5996d0da90042fe7c6e3