예제 #1
0
def match_from_dict(match_dict):
    for old_match, new_match in list(OLD_MATCH_FIELDS.items()):
        if old_match in match_dict:
            match_dict[new_match] = match_dict[old_match]
            del match_dict[old_match]

    kwargs = {}
    for of_match, field in list(match_dict.items()):
        test_config_condition(of_match not in MATCH_FIELDS, 'Unknown match field: %s' % of_match)
        try:
            encoded_field = MATCH_FIELDS[of_match](field)
        except TypeError:
            raise InvalidConfigError('%s cannot be type %s' % (of_match, type(field)))
        kwargs[of_match] = encoded_field

    return parser.OFPMatch(**kwargs)
예제 #2
0
파일: valve_of.py 프로젝트: qasimraz/faucet
def match_from_dict(match_dict):
    for old_match, new_match in list(OLD_MATCH_FIELDS.items()):
        if old_match in match_dict:
            match_dict[new_match] = match_dict[old_match]
            del match_dict[old_match]

    kwargs = {}
    for of_match, field in list(match_dict.items()):
        assert of_match in MATCH_FIELDS, 'Unknown match field: %s' % of_match
        try:
            encoded_field = MATCH_FIELDS[of_match](field)
        except TypeError:
            assert False, '%s cannot be type %s' % (of_match, type(field))
        kwargs[of_match] = encoded_field

    return parser.OFPMatch(**kwargs)
예제 #3
0
def match_from_dict(match_dict):
    for old_match, new_match in OLD_MATCH_FIELDS.items():
        if old_match in match_dict:
            match_dict[new_match] = match_dict[old_match]
            del match_dict[old_match]

    kwargs = {}
    for of_match, field in match_dict.items():
        test_config_condition(of_match not in MATCH_FIELDS, 'Unknown match field: %s' % of_match)
        try:
            encoded_field = MATCH_FIELDS[of_match](field)
        except TypeError:
            raise InvalidConfigError('%s cannot be type %s' % (of_match, type(field)))
        kwargs[of_match] = encoded_field

    return parser.OFPMatch(**kwargs)