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
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
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"
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
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
Merge "Sync jsonutils from openstack-common."
Merge "Make metadata content match the requested version of the metadata API."
Remove obsolete line in host_manager

Change-Id: Ic0b04953f27467dfa479dc94582a4c2d3480f53d
Merge "Fixes XenAPI driver import in vm_vdi_cleaner"
Info log to see which compute driver has loaded

Adding this log will help keep track if the
intended compute driver has loaded or it has been
misconfigured.

fixes bug 1021417

Change-Id: I6fd9e3b45aad36056882e8cef12b90bb8d7aea7b
Merge "Support EC2 CreateImage API for boot-from-volume"