Andrew | 809df1c | 2014-06-27 14:28:53 -0700 | [diff] [blame] | 1 | #! /usr/bin/python |
| 2 | |
| 3 | import json |
| 4 | import requests |
| 5 | |
| 6 | |
| 7 | url = 'http://127.0.0.1:8080/wm/onos/datagrid/add/intents/json' |
| 8 | headers = {'Content-type': 'application/json', 'Accept': 'application/json'} |
| 9 | |
| 10 | |
| 11 | for i in range(6,16): |
| 12 | srcMac = '00:00:00:00:00:'+ str(hex(i)[2:]).zfill(2) |
| 13 | dstMac = '00:00:00:00:00:'+ str(hex(i+10)[2:]) |
| 14 | srcSwitch = '00:00:00:00:00:00:10:'+ str(i).zfill(2) |
| 15 | dstSwitch = '00:00:00:00:00:00:20:'+ str(i+25) |
| 16 | srcPort = 1 |
| 17 | dstPort = 1 |
| 18 | |
| 19 | intent = [{'intent_id': '%d' %(i),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':srcSwitch,'srcPort':srcPort,'srcMac':srcMac,'dstSwitch':dstSwitch,'dstPort':dstPort,'dstMac':dstMac}] |
| 20 | r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers) |
| 21 | #print json.dumps(intent, sort_keys = True) |
| 22 | |
| 23 | intent = [{'intent_id': '%d' %(i+10),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':dstSwitch,'srcPort':dstPort,'srcMac':dstMac,'dstSwitch':srcSwitch,'dstPort':srcPort,'dstMac':srcMac}] |
| 24 | #print json.dumps(intent, sort_keys = True) |
| 25 | r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers) |
| 26 | |