_spreads = ["gauss", "linear", "first"] # possible defined spreads at the moment
_default_flow_template_json = { # templease used for config datastore
- u"flow": [
+ "flow": [
{
- u"hard-timeout": 65000,
- u"idle-timeout": 65000,
- u"cookie_mask": 4294967295,
- u"flow-name": u"FLOW-NAME-TEMPLATE",
- u"priority": 2,
- u"strict": False,
- u"cookie": 0,
- u"table_id": 0,
- u"installHw": False,
- u"id": u"FLOW-ID-TEMPLATE",
- u"match": {
- u"ipv4-destination": u"0.0.0.0/32",
- u"ethernet-match": {u"ethernet-type": {u"type": 2048}},
+ "hard-timeout": 65000,
+ "idle-timeout": 65000,
+ "cookie_mask": 4294967295,
+ "flow-name": "FLOW-NAME-TEMPLATE",
+ "priority": 2,
+ "strict": False,
+ "cookie": 0,
+ "table_id": 0,
+ "installHw": False,
+ "id": "FLOW-ID-TEMPLATE",
+ "match": {
+ "ipv4-destination": "0.0.0.0/32",
+ "ethernet-match": {"ethernet-type": {"type": 2048}},
},
- u"instructions": {
- u"instruction": [
+ "instructions": {
+ "instruction": [
{
- u"order": 0,
- u"apply-actions": {
- u"action": [{u"drop-action": {}, u"order": 0}]
- },
+ "order": 0,
+ "apply-actions": {"action": [{"drop-action": {}, "order": 0}]},
}
]
},
fl1 = flows[0]
sw, tab, fl, ip = fl1
url = "http://" + cntl + ":" + "8181"
- url += "/restconf/config/opendaylight-inventory:nodes/node/openflow:" + str(sw)
- url += "/table/" + str(tab) + "/flow/" + str(fl)
+ url += "/rests/data/opendaylight-inventory:nodes/node=openflow%3A" + str(sw)
+ url += "/flow-node-inventory:table=" + str(tab) + "/flow=" + str(fl)
flow = copy.deepcopy(template["flow"][0])
flow["cookie"] = fl
flow["flow-name"] = "TestFlow-%d" % fl
req = requests.Request(
"PUT",
url,
- headers={"Content-Type": "application/json"},
+ headers={"Content-Type": "application/yang-data+json"},
data=req_data,
auth=("admin", "admin"),
)
sw, tab, fl, ip = fl1
url = "http://" + cntl + ":" + "8181"
url += (
- "/restconf/config/opendaylight-inventory:nodes/node/openflow:"
+ "/rests/data/opendaylight-inventory:nodes/node=openflow%3A"
+ str(sw)
- + "/table/"
+ + "/flow-node-inventory:table="
+ str(tab)
)
fdets = []
req = requests.Request(
"POST",
url,
- headers={"Content-Type": "application/json"},
+ headers={"Content-Type": "application/yang-data+json"},
data=req_data,
auth=("admin", "admin"),
)
fl1 = flows[0]
sw, tab, fl, ip = fl1
url = "http://" + cntl + ":" + "8181"
- url += "/restconf/config/opendaylight-inventory:nodes/node/openflow:" + str(sw)
- url += "/table/" + str(tab) + "/flow/" + str(fl)
+ url += "/rests/data/opendaylight-inventory:nodes/node=openflow%3A" + str(sw)
+ url += "/flow-node-inventory:table=" + str(tab) + "/flow=" + str(fl)
req = requests.Request(
"DELETE",
url,
- headers={"Content-Type": "application/json"},
+ headers={"Content-Type": "application/yang-data+json"},
auth=("admin", "admin"),
)
return req
"""
f1 = flows[0]
sw, tab, fl, ip = f1
- url = "http://" + cntl + ":" + "8181/restconf/operations/sal-bulk-flow:" + method
+ url = "http://" + cntl + ":" + "8181/rests/operations/sal-bulk-flow:" + method
fdets = []
for sw, tab, fl, ip in flows:
flow = copy.deepcopy(template["input"]["bulk-flow-item"][0])
req = requests.Request(
"POST",
url,
- headers={"Content-Type": "application/json"},
+ headers={"Content-Type": "application/yang-data+json"},
data=req_data,
auth=("admin", "admin"),
)
"""
f1 = flows[0]
sw, tab, fl, ip = f1
- url = "http://" + cntl + ":" + "8181/restconf/operations/sal-bulk-flow:" + method
+ url = "http://" + cntl + ":" + "8181/rests/operations/sal-bulk-flow:" + method
fdets = []
for sw, tab, fl, ip in flows:
flow = copy.deepcopy(template["input"]["bulk-flow-item"][0])
req = requests.Request(
"POST",
url,
- headers={"Content-Type": "application/json"},
+ headers={"Content-Type": "application/yang-data+json"},
data=req_data,
auth=("admin", "admin"),
)
cntl = controllers[0]
counter = [0 for i in range(600)]
loop = True
+ req_no = 0
+ num_errors = 0
while loop:
+ req_no += 1
try:
flowlist = inqueue.get(timeout=1)
except queue.Empty:
try:
rsp = ses.send(prep, timeout=5)
except requests.exceptions.Timeout:
+ print(f"*WARN* [{req_no}] Timeout: {req.method} {req.url}")
counter[99] += 1
+ if counter[99] > 10:
+ print("*ERROR* Too many timeouts.")
+ break
continue
+ else:
+ if rsp.status_code not in [200, 201, 204]:
+ print(
+ f"*WARN* [{req_no}] Status code {rsp.status_code}:"
+ f" {req.method} {req.url}\n{rsp.text}"
+ )
+ num_errors += 1
+ if num_errors > 10:
+ print("*ERROR* Too many errors.")
+ break
counter[rsp.status_code] += 1
res = {}
for i, v in enumerate(counter):
url = (
"http://"
+ controller
- + ":8181/restconf/operational/opendaylight-inventory:nodes"
+ + ":8181/rests/data/opendaylight-inventory:nodes?content=nonconfig"
)
rsp = requests.get(
url,
- headers={"Accept": "application/json"},
+ headers={"Accept": "application/yang-data+json"},
stream=False,
auth=("admin", "admin"),
)
if rsp.status_code != 200:
return None
inv = json.loads(rsp.content)
- if "nodes" not in inv:
+ if "opendaylight-inventory:nodes" not in inv:
return None
- if "node" not in inv["nodes"]:
+ if "node" not in inv["opendaylight-inventory:nodes"]:
return []
- inv = inv["nodes"]["node"]
+ inv = inv["opendaylight-inventory:nodes"]["node"]
switches = [sw for sw in inv if "openflow:" in sw["id"]]
return switches