def update_security_group_rule(context, id, security_group_rule):
LOG.info("<STR_LIT>" %<EOL>(context.tenant_id))<EOL>new_rule = security_group_rule["<STR_LIT>"]<EOL>new_rule = _filter_update_security_group_rule(new_rule)<EOL>with context.session.begin():<EOL><INDENT>rule = db_api.security_group_rule_find(context, id=id,<EOL>scope=db_api.ONE)<EOL>if not rule:<EOL><INDENT>raise sg_ext.SecurityGroupRuleNotFound(id=id)<EOL><DEDENT>db_rule = db_api.security_group_rule_update(context, rule, **new_rule)<EOL>group_id = db_rule.group_id<EOL>group = db_api.security_group_find(context, id=group_id,<EOL>scope=db_api.ONE)<EOL>if not group:<EOL><INDENT>raise sg_ext.SecurityGroupNotFound(id=group_id)<EOL><DEDENT><DEDENT>if group:<EOL><INDENT>_perform_async_update_rule(context, group_id, group, rule.id,<EOL>RULE_UPDATE)<EOL><DEDENT>return v._make_security_group_rule_dict(db_rule)<EOL>
Updates a rule and updates the ports