Merge "Reduce the number of db/rpc calls to get instance rules"

This commit is contained in:
Jenkins 2015-12-30 00:07:27 +00:00 committed by Gerrit Code Review
commit af2d79bafa
2 changed files with 14 additions and 0 deletions

View File

@ -1329,6 +1329,11 @@ def security_group_rule_get_by_security_group(context, security_group_id,
context, security_group_id, columns_to_join=columns_to_join)
def security_group_rule_get_by_instance(context, instance_uuid):
"""Get all rules for a given instance."""
return IMPL.security_group_rule_get_by_instance(context, instance_uuid)
def security_group_rule_destroy(context, security_group_rule_id):
"""Deletes a security group rule."""
return IMPL.security_group_rule_destroy(context, security_group_rule_id)

View File

@ -4356,6 +4356,15 @@ def security_group_rule_get_by_security_group(context, security_group_id,
return query.all()
@require_context
def security_group_rule_get_by_instance(context, instance_uuid):
return (_security_group_rule_get_query(context).
join('parent_group', 'instances').
filter_by(uuid=instance_uuid).
options(joinedload('grantee_group')).
all())
@require_context
def security_group_rule_create(context, values):
return _security_group_rule_create(context, values)