def pair_keys_to_items(items, key):
    """
    Convert the list of key:value dicts (nics or disks) into a dict.
    The key for the new dict is one value of the current dict identified by the
    key parameter. If it does not exist, then the key is the order number in
    the list.
    """
    new_items = {}

    for i, item in enumerate(items):
        new_items[item.get(key, i)] = item

    return new_items