Fix aggregate_get_by_host host filtering

aggregate_get_by_host never actually joins the _hosts relationship,
so aggregates with non-matching hosts are still included in the output.

This change adds the join and improves the tests to cover the bug.

Fixes bug 1201277.

Change-Id: I87ebfe3de193b9ae47e3a2c8350a49d9cc863fb0
(cherry picked from commit 13513a182a54dffb62900a8464529459dd836136)

Conflicts:

	nova/db/sqlalchemy/api.py
	nova/tests/db/test_db_api.py
Fix filtering aggregate metadata by key

Filtering by metadata key has no effect in the following two functions:

    aggregate_metadata_get_by_host
    aggregate_host_get_by_metadata_key

Rely on the explicit join instead of joinedload to load the _metadata
relationship in these functions (indicated by the contains_eager
option), so that filtering by key still applies when the metadata is
collected.

Fixes bug 1201283.

Change-Id: I3e44b5db8d67787bfa14f0e57d30a02a271a8833
(cherry picked from commit 7e8fa8f3e6acac0e510cd1fc5af591f9a321d03a)

Conflicts:

	nova/tests/db/test_db_api.py