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
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
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
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
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
Remove unused get_version_from_href()

This is unused since edf3e39c remove the v1.0 API.

Change-Id: I1f7c6203ffbe0248c7ef9e95a231c05a0113a347
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
Rename get_lock() to _get_lock().

This patch changes get_lock() to _get_lock() in the compute manager.
This method is not used via rpc, so this name change helps clarify that
it is (at least currently) an internal-only function.  Marking it as
such allows the method signature to be changed without updating the RPC
API version and having to maintain backwards compatibility.

Related to blueprint no-db-messaging.

Change-Id: Ib608ba06215e0ab8be23cbd32c284420b5230dba
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
Show all absolute quota limits in /limits.

This change adds currently missing absolute limits to the /limits response.

Fixes bug 1025294

Change-Id: I6a758dd683f70a0d006d5aa2840fcc2cb3243297
Merge "Support EC2 CreateImage API for boot-from-volume"
Merge "Remove unused get_version_from_href()"
Merge "Show all absolute quota limits in /limits."
Merge "Display key_name only if keypairs extension is used"
Update FilterSchedulerTestCase docstring

Change-Id: I91ea24747eba9f0f0090f923c5728ba2b85eb141