Avoid db lookup in info_from_instance().
Avoid db lookup in info_from_instance().

The method info_from_instance() in nova.notifications was doing a db
lookup for the system_metadata for an instance.  This patch updates that
code to get that data from the instance that's passed in instead.  The
rest of the patch are related changes to make that happen.

metadata_to_dict() was needed here.  It lived in nova.compute.utils.
nova.compute.utils already imported nova.notifications, so using it from
there would have created a circular import.  Move the method to
nova.utils instead and update the tree to use it from its new location.

I also noticed that the xen driver had a copy of metdata_to_dict().
This patch removes it and uses the common implementation in nova.utils.

'system_metadata' was added to _extra_keys of the Instance db model so
that it would show up in a serialized instance.  Tests failed without it
as the result of getting instances via the conductor API did not include
system_metadata.  Now it's there.

Part of bp no-db-compute.

Change-Id: I451355fb26ae29f13b71438f7896c448b59f97b0

openstack/oslo.versionedobjects,citrix-openstack-build/oslo.versionedobjects