Updated code to match new rules
[integration/test.git] / tools / odl-mdsal-clustering-tests / clustering-functional-test / settings.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
8 __author__ = "Basheeruddin Ahmed"
9 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
10 __license__ = "New-style BSD"
11 __email__ = "syedbahm@cisco.com"
12
13
14 def getServer():
15     return hostname + ":" + port  # noqa
16
17
18 def getCarsUrl():
19     """Cars resource URL for GET"""
20     return "http://" + getServer() + "/restconf/config/car:cars"
21
22
23 def getPersonsUrl():
24     """People resouce URL for GET"""
25     return "http://" + getServer() + "/restconf/config/people:people"
26
27
28 def getCarPersonUrl():
29     """GET cars persons mapping resource URL"""
30     return "http://" + getServer() + "/restconf/config/car-people:car-people"
31
32
33 def getAddCarUrl():
34     """POST or DELETE URL"""
35     return "http://" + getServer() + "/restconf/config"
36
37
38 def getAddPersonUrl():
39     """POST or DELETE URL"""
40     return "http://" + getServer() + "/restconf/config"
41
42
43 def getAddPersonRpcUrl():
44     """POST URL -using rpc"""
45     return "http://" + getServer() + "/restconf/operations/people:add-person"
46
47
48 def getAddCarPersonUrl():
49     """POST URL for car person mapping"""
50     return "http://" + getServer() + "/restconf/config"
51
52
53 def getBuyCarRpcUrl():
54     """POST URL for buy car rpc"""
55     return "http://" + getServer() + "/restconf/operations/car-purchase:buy-car"
56
57
58 # Template for Car resource payload
59 add_car_payload_template = Template(
60     """
61     {"car:cars":{
62         "car-entry": [
63             {
64                 "id": "$id",
65                 "category": "$category",
66                 "model": "$model",
67                 "manufacturer": "$manufacturer",
68                 "year": "$year"
69             }
70         ]
71     }}
72     """)
73
74 # Template for Person resource payload
75 add_person_payload_template = Template(
76     """
77     {"people:people":{
78         "person": [
79             {
80                 "id": "$personId",
81                 "gender": "$gender",
82                 "age": "$age",
83                 "address": "$address",
84                 "contactNo":"$contactNo"
85             }
86         ]
87     }}
88     """)
89
90 # Template for Car Person mapping  payload
91 add_car_person_template = Template(
92     """
93     {"car-people:car-people":{
94         "car-person": [
95             {
96                 "car-id": "$Id",
97                 "person-id": "$personId"
98             }
99         ]
100     }}
101     """)
102
103 # Template for adding person using RPC
104 add_person_rpc_payload_template = Template(
105     """
106     {
107     "input":
108         {
109             "people:id" : "$personId",
110             "people:gender":"$gender",
111             "people:address" : "$address",
112             "people:contactNo":"$contactNo",
113             "people:age":"$age"
114         }
115     }
116     """)
117
118 # Template for buying car rpc
119 buy_car_rpc_template = Template(
120     """
121     {
122     "input" :
123         {
124             "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
125             "car-purchase:person-id" : "$personId",
126             "car-purchase:car-id" : "$carId"
127         }
128     }
129     """)