From bec64033f8977290ec16862b3cc8d0145860a2fd Mon Sep 17 00:00:00 2001
From: Vishvananda Ishaya <vishvananda@gmail.com>
Date: Mon, 26 Sep 2011 08:34:14 -0700
Subject: [PATCH] Fix the grantee group loading for source groups

Fixes bug 859679.

Change-Id: Ia0b90b8373a02955f23b6dda0495f01511762822
---
 nova/db/sqlalchemy/api.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index df09aebaf..e6c841048 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -2801,14 +2801,13 @@ def security_group_rule_get_by_security_group(context, security_group_id,
         result = session.query(models.SecurityGroupIngressRule).\
                          filter_by(deleted=can_read_deleted(context)).\
                          filter_by(parent_group_id=security_group_id).\
-                         options(joinedload_all('grantee_group')).\
+                         options(joinedload_all('grantee_group.instances')).\
                          all()
     else:
-        # TODO(vish): Join to group and check for project_id
         result = session.query(models.SecurityGroupIngressRule).\
                          filter_by(deleted=False).\
                          filter_by(parent_group_id=security_group_id).\
-                         options(joinedload_all('grantee_group')).\
+                         options(joinedload_all('grantee_group.instances')).\
                          all()
     return result