def parse_mappings(mapping_list):
    """Parse mapping devices list

    parses mapping device list in the form:
    physnet:pci_dev_1,pci_dev_2 or
    function:pci_dev_1,pci_dev_2
    :param mapping_list: list of string pairs in "key:value" format
                    the key part represents the physnet or function name
                    the value part is a list of device name separated by ","
    :returns: a dict of valid fields.
    """
    mapping = {}
    for dev_mapping in mapping_list:
        try:
            physnet_or_function, devices = dev_mapping.split(":", 1)
        except ValueError:
            raise ValueError(("Invalid mapping: '%s'") % dev_mapping)
        physnet_or_function = physnet_or_function.strip()
        if not physnet_or_function:
            raise ValueError(("Missing key in mapping: '%s'") % dev_mapping)
        if physnet_or_function in mapping:
            raise ValueError(
                ("Key %(physnet_or_function)s in mapping: %(mapping)s "
                 "not unique") % {'physnet_or_function': physnet_or_function,
                                  'mapping': dev_mapping})
        mapping[physnet_or_function] = set(dev.strip() for dev in
                                           devices.split("|") if dev.strip())
    return mapping