Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
1
Indexable
Never
import requests
import json

url = "http://localhost:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:2/flow-node-inventory:table/0/flow/jahoda
"

payload = json.dumps({
    "flow": [
        {
            "id": "jahoda",
            "match": {
                "ethernet-match": {
                    "ethernet-type": {
                        "type": "2048"
                    }
                },
                "ipv4-destination": "1.1.1.22/32"
            },
            "instructions": {
                "instruction": [
                    {
                        "order": "0",
                        "apply-actions": {
                            "action": [
                                {
                                    "output-action": {
                                        "output-node-connector": "2"
                                    },
                                    "order": "0"
                                }
                            ]
                        }
                    }
                ]
            },
            "priority": "22",
            "table_id": "0"
        }
    ]
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic YWRtaW46YWRtaW4='
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response)