'Indicates whether the specified rule is already
defined in the given security group.'

def rule_exists(self, security_group, new_rule):

    for rule in security_group['rules']:
        keys = ('group_id', 'cidr', 'from_port', 'to_port', 'protocol')
        for key in keys:
            if (rule.get(key) != new_rule.get(key)):
                break
        else:
            return (rule.get('id') or True)
    return False
