def _clean_term_opts(term_opts):
    '''
    Cleanup the term opts:

    - strip Null and empty valuee, defaulting their value to their base definition from _TERM_FIELDS
    - convert to `nacaddr.IP` fields from `_IP_FILEDS`
    - create lists for those fields requiring it
    '''
    clean_opts = {}
    _services = _get_services_mapping()
    for field, value in six.iteritems(term_opts):
        # firstly we'll process special fields like source_service or destination_services
        # which will inject values directly in the source or destination port and protocol
        if field == 'source_service' and value:
            if isinstance(value, six.string_types):
                value = _make_it_list(clean_opts, field, value)
            log.debug('Processing special source services:')
            log.debug(value)
            for service in value:
                if service and service in _services:
                    # if valid source_service
                    # take the port and protocol values from the global and inject in the term config
                    clean_opts['source_port'] = _make_it_list(clean_opts,
                                                              'source_port',
                                                              _services[service]['port'])
                    clean_opts['protocol'] = _make_it_list(clean_opts,
                                                           'protocol',
                                                           _services[service]['protocol'])
            log.debug('Built source_port field, after processing special source services:')
            log.debug(clean_opts.get('source_port'))
            log.debug('Built protocol field, after processing special source services:')
            log.debug(clean_opts.get('protocol'))
        elif field == 'destination_service' and value:
            if isinstance(value, six.string_types):
                value = _make_it_list(clean_opts, field, value)
            log.debug('Processing special destination services:')
            log.debug(value)
            for service in value:
                if service and service in _services:
                    # if valid destination_service
                    # take the port and protocol values from the global and inject in the term config
                    clean_opts['destination_port'] = _make_it_list(clean_opts,
                                                                   'destination_port',
                                                                   _services[service]['port'])
                    clean_opts['protocol'] = _make_it_list(clean_opts,
                                                           'protocol',
                                                           _services[service]['protocol'])
            log.debug('Built source_port field, after processing special destination services:')
            log.debug(clean_opts.get('destination_service'))
            log.debug('Built protocol field, after processing special destination services:')
            log.debug(clean_opts.get('protocol'))
        # not a special field, but it has to be a valid one
        elif field in _TERM_FIELDS and value and value != _TERM_FIELDS[field]:
            # if not a special field type
            if isinstance(_TERM_FIELDS[field], list):
                value = _make_it_list(clean_opts, field, value)
            if field in _IP_FILEDS:
                # IP-type fields need to be transformed
                ip_values = []
                for addr in value:
                    if six.PY2:
                        addr = six.text_type(addr)
                        # Adding this, as ipaddress would complain about valid
                        # addresses not being valid. #pythonIsFun
                    ip_values.append(capirca.lib.policy.nacaddr.IP(addr))
                value = ip_values[:]
            clean_opts[field] = value
    return clean_opts
Cleanup the term opts:

    - strip Null and empty valuee, defaulting their value to their base definition from _TERM_FIELDS
    - convert to `nacaddr.IP` fields from `_IP_FILEDS`
    - create lists for those fields requiring it