Updated code to match new rules
[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 "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
63
64
65 def getJolokiaURL(hostname, port, shardIndex, shardName):
66     """GET URL for jolokia"""
67     return "http://" + hostname + ":" + port + \
68         "/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-" + \
69         shardIndex + "-" + shardName + ",type=DistributedConfigDatastore"
70
71
72 # Template for Car init resource payload
73 add_car_init_payload_template = Template(
74     """
75     {"car:cars":{
76         "car-entry": [
77             {
78                 "id": "$id",
79                 "category": "$category",
80                 "model": "$model",
81                 "manufacturer": "$manufacturer",
82                 "year": "$year"
83             }
84         ]
85     }}
86     """)
87
88 # Template for Car resource payload
89 add_car_payload_template = Template(
90     """
91         {"car-entry": [
92             {
93                 "id": "$id",
94                 "category": "$category",
95                 "model": "$model",
96                 "manufacturer": "$manufacturer",
97                 "year": "$year"
98             }
99         ]
100     }
101     """)
102
103 # Template for Person resource payload
104 add_person_payload_template = Template(
105     """
106     {"people:people":{
107         "person": [
108             {
109                 "id": "$personId",
110                 "gender": "$gender",
111                 "age": "$age",
112                 "address": "$address",
113                 "contactNo":"$contactNo"
114             }
115         ]
116     }}
117     """)
118
119 # Template for Car Person mapping  payload
120 add_car_person_template = Template(
121     """
122     {"car-people:car-people":{
123         "car-person": [
124             {
125                 "car-id": "$Id",
126                 "person-id": "$personId"
127             }
128         ]
129     }}
130     """)
131
132 # Template for adding person using RPC
133 add_person_rpc_payload_template = Template(
134     """
135     {
136         "input":
137             {
138                 "people:id" : "$personId",
139                 "people:gender":"$gender",
140                 "people:address" : "$address",
141                 "people:contactNo":"$contactNo",
142                 "people:age":"$age"
143             }
144     }
145     """)
146
147 # Template for buing car rpc
148 buy_car_rpc_template = Template(
149     """
150     {
151         "input" :
152         {
153             "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
154             "car-purchase:person-id" : "$personId",
155             "car-purchase:car-id" : "$carId"
156         }
157     }
158     """)