Ensure anti affinity scheduling works

The query for the group in the system_metadata would not correctly
filter the instances with the groups.

Fixes bug: 1218878

Conflicts:
        nova/db/sqlalchemy/api.py
        nova/tests/db/test_db_api.py

Change-Id: I623c73635c36ffa038ae01476a25ba0c0863e536
(cherry picked from commit 4233e16ba2f5bb85e93494b6eeb9ffff31dbdf30)
Merge "Ensure anti affinity scheduling works" into stable/grizzly