Make metadata content match the requested version of the metadata API.

Currently the same metadata is returned no matter what metadata
version is requested. Metadata is currently implemented to version
2009-04-04 (apart from existing TODOs) as defined here:
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html

This change adds version checking conditionals throughout
get_ec2_metadata and only includes the metadata if the requested version
should contain it.

When there is a difference between Amazon API implementation and documentation
I've gone with replicating the implementation. So far differences include:
- undocumented hostname introduced in 1.0, deprecated in favour of
  local-hostname
- kernel-id and ramdisk-id seem have to been implemented in 2007-12-15,
  not 2008-02-01 as documented

get_ec2_metadata has also been reordered so that data is added oldest to
newest by API version. In a future change I may attempt to add
unimplemented API versions (2011-01-01, 2012-06-01).

Change-Id: Ibf6e6e3b9807f29dccd31006515df550bf9bf57b
Properly name openstack.common.exception.

Now it's 'nova.openstack.common.exception', thanks to a more modern
update.py in common.

Change-Id: I4b3caf9014f866da3a5bbf07ab194fc9910159b0
Use _lookup_by_name instead of _conn.lookupByName

use the helper function instead of the libvirt call directly
to allow NovaExceptions instead of libvirt exceptions to be thrown.

Change-Id: Ieac171e1a2bce1f5542ae73f3d8f6b7a5ccfa8f7
General-host-aggregates part 1.

Partially implements blueprint general-host-aggregates: Xen decoupling

* keep rpcapi to compute-controller for Hypervisor-Pools
  *  Add compute_rpcapi.add_aggregate_host to libvirt
* Remove aggregate states
* Remove One aggregate per host restriction
* Keep Xen support for both hypervisor pools and aggregates

Change-Id: I6ac0f8b6fc31dff589363331e99e0755301f2172
Return 413 status on over-quota in the native API.

Related to LP 1021373.

Previously we returned a generic 500 Server Error on an over-quota
conditions, whereas this is arguably more appropriately reported
as a 413 status.

Change-Id: I5c1cdc9db54804c512d60e4179c1faa13516d6f9
Merge "Properly name openstack.common.exception."
Catch rpc up to the common state-of-the-art.

This propagates the following patch from common into nova:

  Author: Jason Kölker <jason@koelker.net>
  Date:   Tue Jul 10 11:12:50 2012 -0500

      Fix Zmq so it doesn't rely on nova flags

      * Embeded newlines in logging makes me cry
      * String formatting uses parens not curly braces
      * Fix LP1023039
      * Hard skip Zmq tests so jenkins passes. Someone will have to fix.

Change-Id: I651aa10861cb26808fa46e74a7db545fb2fd23b8
Refactoring required for blueprint xenapi-live-migration

This refactoring of the libvirt live migration code is
required to enable live migration in the xenapi driver.

This change ensures libvirt specific checks are performed
only when the libvirt driver is enabled.

The complication is that some of these checks require
information to be passed between the source and destination
hosts. For example, when comparing CPU flags.

Change-Id: I7389f0b7f03313d7f04b907f481787dadf0716fd
Remove VDI chain limit for migrations.

The strategy for removing the limit is to refactor migration so that
they work nearly identically to snapshots, meaning sequence-numbered
VHDs are rsynced over into a staging-area and then imported into the SR
using the `import_vhds` function.

Change-Id: Ibf5c82c52ae7d505ea9e54d64fcc8b8fdce4d05d
Adding granularity for quotas to list and update

added quotas:show and quotas:update to policy.json
defaulting quotas:update to an admin-api default

Change-Id: Ib328912be859512b9c5391d9b7aa317ecf29aeab
Merge "Remove VDI chain limit for migrations."
Merge "General-host-aggregates part 1."
Sync jsonutils from openstack-common.

In addition to the following changes from openstack-common, this patch
includes some tweak to nova unit tests.  timeutils.strtime() will raise
an exception if the year in a datetime object is before 1900.

Changes from openstack-common:

    commit ce3071437d1871f77c4d8573cbe5f4ea8c817650
    Author: Russell Bryant <rbryant@redhat.com>
    Date:   Mon Jul 16 10:30:25 2012 -0400

        Use strtime() in to_primitive() for datetime objs.

        This patch updates jsonutils.to_primitive() to use timeutils.strtime()
        to convert a datimetime object to a string instead of just using str().
        This ensures that we can easily convert the string back to a datetime
        using timeutils.parse_strtime().

        Required for the nova blueprint no-db-messaging.

    commit 4c9d439ef24f5afdd74aa9153aa8fc772051e6cb
    Author: Tim Daly Jr <timjr@yahoo-inc.com>
    Date:   Tue Jun 26 02:48:42 2012 +0000

        Add 'filedecoder' method to the jsonutils wrapper module.

        Fixes bug #1017765

        After version 3.3.2, the anyjson library will throw a KeyError if
        filedecoder isn't present.  The filedecoder is just like the decoder
        except it takes a file instead of a string, like json.load() instead
        of json.loads().

Change-Id: Ib51f0da8641c035371e09047de9abe3cb83203e9
Merge "Return 413 status on over-quota in the native API."
Merge "Refactoring required for blueprint xenapi-live-migration"
Partially implements blueprint xenapi-live-migration

This is dependent on refactoring of libvirt live migration.

Enables live migration using xenapi:
* works when both hosts are part of the same aggregate
* assumes shared storage is configured as the default SR

Limitations in this version:
* only works for images that don't have an external
  ramdisk/kernel

Change-Id: I74fc6aae9a615be7cefb1cf07755764df1af957a
remove unused clauses[] variable

This seems to have been left over from a prior implementation.
Remove it for code hygene.

Change-Id: I6181713c3228632a50af055109f60728ab0f22e4
Support EC2 CreateImage API for boot-from-volume

Fixes bug lp 988335

For fidelity with AWS, where the EC2 CreateImage API is only
supported for EBS-backed instances, we now support this API
for booted-from-volume nova servers.

We create a "place-holder" image in glance with the image data
being effectively empty, and the following properties set:

  * the imaged instance's kernel and ramdisk IDs
  * block device mapping containing the appropriate snapshot ID(s)

so that we can boot from this image without providing additional
context (such as via the nova boot --block-device-mapping option)

Change-Id: I0b3d18d7922f2ad1bc687fa88e2f5d4cf5aa068b
Display key_name only if keypairs extension is used

GET /servers/xxx will display the key_name only if the keypairs extension is
being used.

Fixes bug 1024986

Change-Id: Ie37880f63b7595ae3dd2f3b23c6c3097dac2f57c
Fixes XenAPI driver import in vm_vdi_cleaner

xenapi/connection.py was renamed xenapi/driver.py, it appears, but
vm_vdi_cleaner was not updated.

Also removed unused optparse import.

Fixes bug 1025912

Change-Id: Ia1a93400dc24455fe91fdf4283eb32bcca4037cf