use REDIRECT to forward local metadata request

VMs can not get metadata when metadata_host is set to 127.0.0.1 because
packet's destination address will be changed into 127.0.0.1 by iptables.
However, linux kernel will reject packets to 127.0.0.0/8 if packets do not
come from that range. We can use REDIRECT to resolve this problem because
REDIRECT will rewrite the destination address to our own host.

Fixes bug 1015853.

Change-Id: I162fc57510ef9c8e84130b2d11eb53e10dcc5cb0
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
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
Flavor extra specs extension use instance_type id

bug 1031263

The nova database API use instance_type id as parameter to access flavor
extra spec. However, the flavor extra_specs API extension use flavor_id as
parameter wrongly.

As the instance_type ID is a purely nova internal ID, the database should
not expose it and instead use flavor_id as the parameter

Change-Id: I5f509cb7c4457d8c399df32f559a874d498be762
Signed-off-by: Yunhong, Jiang <yunhong.jiang@intel.com>
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>
Move results filtering to  db.

This patch moves exact filter and regex filter matching on the listing of
instances to the database query. This is important so that we can eventually do
all pagination through the database.

If the db backend does not support regex matching then the SQL 'LIKE' operator
will be used instead.

Change-Id: If9dd644066787f0f3667992f23e5c33b1dc90286
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
Driver for IBM Storwize and SVC storage.

Volume driver for IBM Storwize and SVC storage systems, along with unit
tests and updated sample config file. The unit tests include a
Storwize/SVC management simulator to allow for testing without
controller hardware. Also added a new exception for volume drivers.

Co-authored-by: Ronen Kat <ronenkat@il.ibm.com>

Change-Id: I3fe9cfcca8d4bddb71c763b526105e34f2652557
Uniqueness checks for floating ip addresses.

Fixes bug 1003392.

Change-Id: I3f4554659c68476539c82d359cc080b34088b3ae
Make TerminateInstances compatible with EC2 api

fixes bug 1034377

Currently the XML response for TerminateInstances differs
from the EC2 api specifications and causes the .net EC2 api
from Amazon to crash.

Change-Id: I14172318ed4dc2af16c45be376475885f474c545
Fixes KeyError when trying to rescue an instance

When rescuing an instance, a KeyError exception is thrown since
the 'injected_files' key doesn't exist in the instance dict.

Change-Id: I733899c3f699803db4dbe95021b1cb6490392bed
Adds ability to inherit wsgi extensions

Needed for blueprint disable-server-extensions

It is possible to create a wsgi resource that extends another
resource by using the same controller, but any extensions that
have been applied to the original resource will have no affect.

This adds a new parameter to ResourceExtension that allows it
to inherit extensions from another resource. This is necessary
because we are moving key funcionality of the /servers resource
into extensions, and some other resources (like create-server-ext)
extend that functionality. This way we can keep the functionality
of the other extensions.

Change-Id: I21b4c2569c35d59c1f466642355564084a277aea
Moves security group functionality into extension

partially implements blueprint disable-server-extensions

This patch adds an output extension for security group output
and modifies the servers code to only allow security groups
to be specified if the os-security-groups extension is
enabled.

Duplicated security group functionality was removed from the
createserverext extension, it is now a duplicate of the servers
endpoint. The boot_from_volume extension was also changed
to inherit the servers functionality so that security_groups
will continue to work. The block_device_mapping code will be
modified in a subsequent patch.

Tests were added for new functionality, and existing tests were
modified slightly. The disk_config extension was modified to be
a bit more lenient so the data for it doesn't need to be mocked
out in other tests.

Change-Id: I59bd985d68b85ce6926cde85fbc38cfad4e75f4c
Key block_device_mapping off of volume extension

partially implements blueprint disable-server-extensions

Instead of creating a child controller for boot from volume,
key the post parameter of of the os-volumes extension.

Change-Id: I0dd233c2ae12a09d6fc59c49042c2f8b83f3fdba
Key user_data in create server off of extension

Implements part of blueprint disable-server-extensions

Adds a new extension descriptor for user_data and makes sure that
user_data is only accepted in the create server request if the
extension is enabled.

Change-Id: I7aef0ebe569da841adbf380d5695c9029fb3b002
Fix setting admin_pass in rescue command

Fixes bug 1034948

The database doesn't have an admin_pass column, so the instance_update()
call is a noop.

Change-Id: I9f22de1e926ed48b8fd4561ddf2129db6a1e0b65
Fix stale instances being sent over rpc.

There were a number of places in compute/api.py that were calling
self.update() for an instance, but not sending an instance that contains
those updates over rpc.  This patch fixes them.

The changes to the unit tests were required because its stubs were
returning an instance without a host set in some cases.  So, the result
of self.update() had no host and the rpcapi would blow up since it had
no idea where to send the message.

This patch does not fix self.update() before prep_resize, because it is
being addressed in this patch: https://review.openstack.org/#/c/11050/

Change-Id: I4efc922a6a0af0605d4d63012d55ff8473211fd5
Create unique volumes_dir for testing.

Updates several Nova volume test classes so that we create a
unique volumes_dir for testing. This avoids polluting the source
tree with fake volume UUID's when running tests.

Note: I opted to go utils.tempdir in test_volume (which seemed
cleaner). I did not however use utils.tempdir in the other
test modules since it would have required a good be more
reformatting effort...

Change-Id: I24a53c28c52156750cf65942639af0b15fbeefc1
Merge "Fix setting admin_pass in rescue command"
Merge "Adds ability to inherit wsgi extensions"