-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpostflow.py
More file actions
71 lines (65 loc) · 1.95 KB
/
Copy pathpostflow.py
File metadata and controls
71 lines (65 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import json
import requests
action = 'POST'
# path = 'http://192.168.56.101:8181/onos/v1/flows/'
server = '192.168.56.101'
port = '8181'
path = '/onos/v1/flows/'
device1 = 'of:0000000000000001'
device2 = 'of:0000000000000002'
session = requests.Session()
session.auth = ('onos', 'rocks')
datas = []
data = {
"priority": 10,
"timeout": 0,
"isPermanent": True,
"deviceId": "of:0000000000000001",
"treatment":
{"instructions": [{"type":"OUTPUT","port":"3"}]},
"selector":
{"criteria":[{"type":"IN_PORT","port":1},
{"type":"ETH_DST","mac":"00:00:00:00:00:02"},
{"type":"ETH_SRC","mac":"00:00:00:00:00:01"}]}}
datas.append(data)
data = {
"priority": 10,
"timeout": 0,
"isPermanent": True,
"deviceId": "of:0000000000000001",
"treatment":
{"instructions": [{"type":"OUTPUT","port":"1"}]},
"selector":
{"criteria":[{"type":"IN_PORT","port":2},
{"type":"ETH_DST","mac":"00:00:00:00:00:01"},
{"type":"ETH_SRC","mac":"00:00:00:00:00:02"}]}}
datas.append(data)
data = {
"priority": 10,
"timeout": 0,
"isPermanent": True,
"deviceId": "of:0000000000000002",
"treatment":
{"instructions":[{"type":"OUTPUT","port":"2"}]},
"selector":
{"criteria":[{"type":"IN_PORT","port":1},
{"type":"ETH_DST","mac":"00:00:00:00:00:01"},
{"type":"ETH_SRC","mac":"00:00:00:00:00:02"}]}}
datas.append(data)
data = {
"priority": 10,
"timeout": 0,
"isPermanent": True,
"deviceId": "of:0000000000000002",
"treatment":
{"instructions":[{"type":"OUTPUT","port":"1"}]},
"selector":
{"criteria":[{"type":"IN_PORT","port":3},
{"type":"ETH_DST","mac":"00:00:00:00:00:02"},
{"type":"ETH_SRC","mac":"00:00:00:00:00:01"}]}}
datas.append(data)
for data in datas:
req = requests.Request(action, 'http://%s:%s%s%s' % (server, port, path, data["deviceId"]),
data=json.dumps(data), auth=session.auth)
resp = session.send(req.prepare())
resp.raise_for_status()