def _rules_present(name, rules, delete_ingress_rules=True, vpc_id=None,
                   vpc_name=None, region=None, key=None, keyid=None, profile=None):
    '''
    given a group name or group name and vpc_id (or vpc name):
    1. get lists of desired rule changes (using _get_rule_changes)
    2. authorize/create rules missing rules
    3. if delete_ingress_rules is True, delete/revoke non-requested rules
    4. return 'old' and 'new' group rules
    '''
    ret = {'result': True, 'comment': '', 'changes': {}}
    sg = __salt__['boto_secgroup.get_config'](name=name, group_id=None, region=region, key=key,
                                              keyid=keyid, profile=profile, vpc_id=vpc_id,
                                              vpc_name=vpc_name)
    if not sg:
        ret['comment'] = '{0} security group configuration could not be retrieved.'.format(name)
        ret['result'] = False
        return ret
    rules = _split_rules(rules)
    if vpc_id or vpc_name:
        for rule in rules:
            _source_group_name = rule.get('source_group_name', None)
            if _source_group_name:
                _group_vpc_name = vpc_name
                _group_vpc_id = vpc_id
                _source_group_name_vpc = rule.get('source_group_name_vpc', None)
                if _source_group_name_vpc:
                    _group_vpc_name = _source_group_name_vpc
                    _group_vpc_id = None
                _group_id = __salt__['boto_secgroup.get_group_id'](
                    name=_source_group_name, vpc_id=_group_vpc_id, vpc_name=_group_vpc_name,
                    region=region, key=key, keyid=keyid, profile=profile
                )
                if not _group_id:
                    raise SaltInvocationError(
                        'source_group_name {0} does not map to a valid '
                        'source group id.'.format(_source_group_name)
                    )
                rule['source_group_name'] = None
                if _source_group_name_vpc:
                    rule.pop('source_group_name_vpc')
                rule['source_group_group_id'] = _group_id
    # rules = rules that exist in salt state
    # sg['rules'] = that exist in present group
    to_delete, to_create = _get_rule_changes(rules, sg['rules'])
    to_delete = to_delete if delete_ingress_rules else []
    if to_create or to_delete:
        if __opts__['test']:
            msg = """Security group {0} set to have rules modified.
            To be created: {1}
            To be deleted: {2}""".format(name, pprint.pformat(to_create),
                                         pprint.pformat(to_delete))
            ret['comment'] = msg
            ret['result'] = None
            return ret
        if to_delete:
            deleted = True
            for rule in to_delete:
                _deleted = __salt__['boto_secgroup.revoke'](
                    name, vpc_id=vpc_id, vpc_name=vpc_name, region=region,
                    key=key, keyid=keyid, profile=profile, **rule)
                if not _deleted:
                    deleted = False
            if deleted:
                ret['comment'] = 'Removed rules on {0} security group.'.format(name)
            else:
                ret['comment'] = 'Failed to remove rules on {0} security group.'.format(name)
                ret['result'] = False
        if to_create:
            created = True
            for rule in to_create:
                _created = __salt__['boto_secgroup.authorize'](
                    name, vpc_id=vpc_id, vpc_name=vpc_name, region=region,
                    key=key, keyid=keyid, profile=profile, **rule)
                if not _created:
                    created = False
            if created:
                ret['comment'] = ' '.join([
                    ret['comment'],
                    'Created rules on {0} security group.'.format(name)
                ])
            else:
                ret['comment'] = ' '.join([
                    ret['comment'],
                    'Failed to create rules on {0} security group.'.format(name)
                ])
                ret['result'] = False
        ret['changes']['old'] = {'rules': sg['rules']}
        sg = __salt__['boto_secgroup.get_config'](name=name, group_id=None, region=region, key=key,
                                                  keyid=keyid, profile=profile, vpc_id=vpc_id,
                                                  vpc_name=vpc_name)
        ret['changes']['new'] = {'rules': sg['rules']}
    return ret