'Remove a rule to the SecurityGroup object.  Note that this method
only changes the local version of the object.  No information
is sent to EC2.'

def remove_rule(self, ip_protocol, from_port, to_port, src_group_name, src_group_owner_id, cidr_ip, src_group_group_id, dry_run=False):

    if (not self.rules):
        raise ValueError('The    security    group    has    no    rules')
    target_rule = None
    for rule in self.rules:
        if (rule.ip_protocol == ip_protocol):
            if (rule.from_port == from_port):
                if (rule.to_port == to_port):
                    target_rule = rule
                    target_grant = None
                    for grant in rule.grants:
                        if ((grant.name == src_group_name) or (grant.group_id == src_group_group_id)):
                            if (grant.owner_id == src_group_owner_id):
                                if (grant.cidr_ip == cidr_ip):
                                    target_grant = grant
                    if target_grant:
                        rule.grants.remove(target_grant)
        if (len(rule.grants) == 0):
            self.rules.remove(target_rule)
