Merge "Renamed populate.py to crud.py Fixed method call name change Signed-off-by...
[integration/test.git] / test / tools / odl-mdsal-clustering-tests / clustering-functional-test / util.py
1 __author__ = "Basheeruddin Ahmed"
2 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
3 __license__ = "New-style BSD"
4 __email__ = "syedbahm@cisco.com"
5
6
7 import urllib
8 from urllib import request
9 import json
10 import requests
11 import socket
12
13
14 #
15 #Helps in making GET REST calls
16 #
17
18 def get(url, userId, password):
19
20     headers = {}
21     headers['Accept']= 'application/xml'
22
23     # Send the GET request
24     req = urllib.request.Request(url, None, headers)
25
26     # Read the response
27     return urllib.request.urlopen(req).read()
28
29 #
30 #Helps in making POST REST calls without outputs
31 #
32 def nonprintpost(url, userId, password,data):
33
34     headers = {}
35     headers['Content-Type'] = 'application/json'
36     #headers['Accept']= 'application/xml'
37
38     resp = requests.post(url,data.encode(),headers=headers)
39
40
41     return resp
42
43 #
44 #Helps in making POST REST calls
45 #
46 def post(url, userId, password,data):
47     print("post request with url "+url)
48     print("post request with data "+data)
49     headers = {}
50     headers['Content-Type'] = 'application/json'
51     #headers['Accept']= 'application/xml'
52
53     resp = requests.post(url,data.encode(),headers=headers)
54
55     #print (resp.raise_for_status())
56     print (resp.headers)
57
58     return resp
59
60 #
61 #Helps in making DELET REST calls
62 #
63 def delete(url,userId,password):
64     print("delete all resources belonging to url"+url)
65     resp=requests.delete(url)
66
67