Correctly space expected_status
[integration/test.git] / csit / libraries / SettingsLibrary.py
1 from string import Template
2
3 # helps in taking the hostname entered by the user
4 # global hostname
5 # global port
6
7 __author__ = "Basheeruddin Ahmed"
8 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
9 __license__ = "New-style BSD"
10 __email__ = "syedbahm@cisco.com"
11
12
13 # def setHostname(host):
14 #     hostname=host
15
16 # def getServer():
17 #     return hostname +":"+"8080"
18
19
20 def getCarsUrl(hostname, port):
21     """Cars resource URL for GET"""
22     return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
23
24
25 def getPersonsUrl(hostname, port):
26     """People resouce URL for GET"""
27     return "http://" + hostname + ":" + port + "/restconf/config/people:people"
28
29
30 def getCarPersonUrl(hostname, port):
31     """GET cars persons mapping resource URL"""
32     return "http://" + hostname + ":" + port + "/restconf/config/car-people:car-people"
33
34
35 def getAddCarInitUrl(hostname, port):
36     """POST or DELETE URL"""
37     return "http://" + hostname + ":" + port + "/restconf/config"
38
39
40 def getAddCarUrl(hostname, port):
41     """POST or DELETE URL"""
42     return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
43
44
45 def getAddPersonUrl(hostname, port):
46     """POST or DELETE URL"""
47     return "http://" + hostname + ":" + port + "/restconf/config"
48
49
50 def getAddPersonRpcUrl(hostname, port):
51     """POST URL -using rpc"""
52     return "http://" + hostname + ":" + port + "/restconf/operations/people:add-person"
53
54
55 def getAddCarPersonUrl(hostname, port):
56     """POST URL for car person mapping"""
57     return "http://" + hostname + ":" + port + "/restconf/config"
58
59
60 def getBuyCarRpcUrl(hostname, port):
61     """POST URL for buy car rpc"""
62     return (
63         "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
64     )
65
66
67 def getJolokiaURL(hostname, port, shardIndex, shardName):
68     """GET URL for jolokia"""
69     return (
70         "http://"
71         + hostname
72         + ":"
73         + port
74         + "/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-"
75         + shardIndex
76         + "-"
77         + shardName
78         + ",type=DistributedConfigDatastore"
79     )
80
81
82 # Template for Car init resource payload
83 add_car_init_payload_template = Template(
84     """
85     {"car:cars":{
86         "car-entry": [
87             {
88                 "id": "$id",
89                 "category": "$category",
90                 "model": "$model",
91                 "manufacturer": "$manufacturer",
92                 "year": "$year"
93             }
94         ]
95     }}
96     """
97 )
98
99 # Template for Car resource payload
100 add_car_payload_template = Template(
101     """
102         {"car-entry": [
103             {
104                 "id": "$id",
105                 "category": "$category",
106                 "model": "$model",
107                 "manufacturer": "$manufacturer",
108                 "year": "$year"
109             }
110         ]
111     }
112     """
113 )
114
115 # Template for Person resource payload
116 add_person_payload_template = Template(
117     """
118     {"people:people":{
119         "person": [
120             {
121                 "id": "$personId",
122                 "gender": "$gender",
123                 "age": "$age",
124                 "address": "$address",
125                 "contactNo":"$contactNo"
126             }
127         ]
128     }}
129     """
130 )
131
132 # Template for Car Person mapping  payload
133 add_car_person_template = Template(
134     """
135     {"car-people:car-people":{
136         "car-person": [
137             {
138                 "car-id": "$Id",
139                 "person-id": "$personId"
140             }
141         ]
142     }}
143     """
144 )
145
146 # Template for adding person using RPC
147 add_person_rpc_payload_template = Template(
148     """
149     {
150         "input":
151             {
152                 "people:id" : "$personId",
153                 "people:gender":"$gender",
154                 "people:address" : "$address",
155                 "people:contactNo":"$contactNo",
156                 "people:age":"$age"
157             }
158     }
159     """
160 )
161
162 # Template for buing car rpc
163 buy_car_rpc_template = Template(
164     """
165     {
166         "input" :
167         {
168             "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
169             "car-purchase:person-id" : "$personId",
170             "car-purchase:car-id" : "$carId"
171         }
172     }
173     """
174 )