Merge "TSDR HBase and H2 DataStore Integrations Test suites and following review...
[integration/test.git] / test / csit / libraries / SettingsLibrary.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 from string import Template
7
8 # helps in taking the hostname entered by the user
9 # global hostname
10 # global port
11
12 # def setHostname(host):
13 #     hostname=host
14
15 # def getServer():
16 #     return hostname +":"+"8080"
17
18
19 def getCarsUrl(hostname, port):
20     """Cars resource URL for GET"""
21     return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
22
23
24 def getPersonsUrl(hostname, port):
25     """People resouce URL for GET"""
26     return "http://" + hostname + ":" + port + "/restconf/config/people:people"
27
28
29 def getCarPersonUrl(hostname, port):
30     """GET cars persons mapping resource URL"""
31     return "http://" + hostname + ":" + port + "/restconf/config/car-people:car-people"
32
33
34 def getAddCarUrl(hostname, port):
35     """POST or DELETE URL"""
36     return "http://" + hostname + ":" + port + "/restconf/config"
37
38
39 def getAddPersonUrl(hostname, port):
40     """POST or DELETE URL"""
41     return "http://" + hostname + ":" + port + "/restconf/config"
42
43
44 def getAddPersonRpcUrl(hostname, port):
45     """POST URL -using rpc"""
46     return "http://" + hostname + ":" + port + "/restconf/operations/people:add-person"
47
48
49 def getAddCarPersonUrl(hostname, port):
50     """POST URL for car person mapping"""
51     return "http://" + hostname + ":" + port + "/restconf/config"
52
53
54 def getBuyCarRpcUrl(hostname, port):
55     """POST URL for buy car rpc"""
56     return "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
57
58
59 def getJolokiaURL(hostname, port, shardIndex, shardName):
60     """GET URL for jolokia"""
61     return "http://" + hostname + ":" + port + \
62         "/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-" + \
63         shardIndex + "-" + shardName + ",type=DistributedConfigDatastore"
64
65
66 # Template for Car resource payload
67 add_car_payload_template = Template(
68     """
69     {"car:cars":{
70         "car-entry": [
71             {
72                 "id": "$id",
73                 "category": "$category",
74                 "model": "$model",
75                 "manufacturer": "$manufacturer",
76                 "year": "$year"
77             }
78         ]
79     }}
80     """)
81
82 # Template for Person resource payload
83 add_person_payload_template = Template(
84     """
85     {"people:people":{
86         "person": [
87             {
88                 "id": "$personId",
89                 "gender": "$gender",
90                 "age": "$age",
91                 "address": "$address",
92                 "contactNo":"$contactNo"
93             }
94         ]
95     }}
96     """)
97
98 # Template for Car Person mapping  payload
99 add_car_person_template = Template(
100     """
101     {"car-people:car-people":{
102         "car-person": [
103             {
104                 "car-id": "$Id",
105                 "person-id": "$personId"
106             }
107         ]
108     }}
109     """)
110
111 # Template for adding person using RPC
112 add_person_rpc_payload_template = Template(
113     """
114     {
115         "input":
116             {
117                 "people:id" : "$personId",
118                 "people:gender":"$gender",
119                 "people:address" : "$address",
120                 "people:contactNo":"$contactNo",
121                 "people:age":"$age"
122             }
123     }
124     """)
125
126 # Template for buing car rpc
127 buy_car_rpc_template = Template(
128     """
129     {
130         "input" :
131         {
132             "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
133             "car-purchase:person-id" : "$personId",
134             "car-purchase:car-id" : "$carId"
135         }
136     }
137     """)