def change_flowspace(fv, change):
    import re
    slice_re = re.compile(r"Slice:(?P<name>.+)=(?P<perms>\d+)")
    axn_matches = slice_re.findall(change['actions'])
    for axn in axn_matches:
        try:
            slice = DummyFVSlice.objects.filter(
                fv=fv).get(name=axn.group("name"))
        except DummyFVSlice.DoesNotExist:
            raise Exception(
                "Tried to change flowspace for non-existing slice %s" %\
                axn.group("name")
            )
    try:
        rule = DummyFVRule.objects.filter(fv=fv).get(id=change['id'])
    except DummyFVRule.DoesNotExist:
        raise Exception("Tried to change flowspace for non-existing " + \
                        "rule id %s" % change['id'])

    rule.match = change['match']
    rule.dpid = change['dpid']
    rule.actions = change['actions']
    rule.priority = int(change['priority'])
    rule.save()
    return rule.id
dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/optin_manager/dummyfv/rpc.py/change_flowspace/original