'Returns set of metadata restricted to required fields.
If fields is empty list, the full set is returned.
:param metadata: master set of metadata
:param fields: list of fields we want to extract
:param excludes: fields to be excluded
:returns: filtered metadata'

@staticmethod
def _filter(metadata, fields, excludes=None):

    if (not fields):
        return metadata
    if (not excludes):
        excludes = []
    subset = {}
    for field in fields:
        if ((field in metadata) and (field not in excludes)):
            subset[field] = metadata[field]
        else:
            LOG.debug("Excluding    field    '%s'", field)
    return subset
