blob: 10bb5d4f68ecacd5fb1b399a2929c7ed74685dcd [file] [log] [blame]
SeanCorcoran60b6b502014-04-23 16:53:39 -07001#! /usr/bin/env python
2
3'''
4This file removes the ONOS intents for the sanity 4 nodes tests. The flows associated with these intents should be deleted from the switches.
5'''
6
7import json
8import requests
9
10
11
12url = 'http://127.0.0.1:8080/wm/onos/datagrid/add/intents/json'
13headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
14
15
16'''response
17[{'intent_id':'5','status':'CREATED','log':['created, time:73268214932534']}]
18'''
19
20
21
22for i in range(6,16):
23 #intent = [{'intent_id': '%d' %i,'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':'8249','srcPort':1,'srcMac':'00:00:00:00:00:01','dstSwitch':'4103','dstPort':1,'dstMac':'00:00:00:00:00:02'}]
24 srcMac = '00:00:00:00:00:'+ str(hex(i)[2:]).zfill(2)
25 dstMac = '00:00:00:00:00:'+ str(hex(i+10)[2:])
26 srcSwitch = '00:00:00:00:00:00:10:'+ str(i).zfill(2)
27 dstSwitch = '00:00:00:00:00:00:20:'+ str(i+25)
28 srcPort = 1
29 dstPort = 1
30
31 intent = [{'intent_id': '%d' %(i),'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':srcSwitch,'srcPort':srcPort,'srcMac':srcMac,'dstSwitch':dstSwitch,'dstPort':dstPort,'dstMac':dstMac}]
32
33
34 print json.dumps(intent, sort_keys = True)
35
36
37 #r = requests.post(url, data=json.dumps(iid, sort_keys=True)+json.dumps(intent, sort_keys=True), headers = headers)
38 r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
39 print r
40 print r.content
41
42
43
44 intent = [{'intent_id': '%d' %(i+10),'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':dstSwitch,'srcPort':dstPort,'srcMac':dstMac,'dstSwitch':srcSwitch,'dstPort':srcPort,'dstMac':srcMac}]
45 print json.dumps(intent, sort_keys = True)
46 r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
47 print r
48 print r.content
49