e47c420707a3fc9c6feed7a99273fce5dded08ec
[integration/test.git] / 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 getAddCarInitUrl(hostname, port):
35     """POST or DELETE URL"""
36     return "http://" + hostname + ":" + port + "/restconf/config"
37
38
39 def getAddCarUrl(hostname, port):
40     """POST or DELETE URL"""
41     return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
42
43
44 def getAddPersonUrl(hostname, port):
45     """POST or DELETE URL"""
46     return "http://" + hostname + ":" + port + "/restconf/config"
47
48
49 def getAddPersonRpcUrl(hostname, port):
50     """POST URL -using rpc"""
51     return "http://" + hostname + ":" + port + "/restconf/operations/people:add-person"
52
53
54 def getAddCarPersonUrl(hostname, port):
55     """POST URL for car person mapping"""
56     return "http://" + hostname + ":" + port + "/restconf/config"
57
58
59 def getBuyCarRpcUrl(hostname, port):
60     """POST URL for buy car rpc"""
61     return "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
62
63
64 def getJolokiaURL(hostname, port, shardIndex, shardName):
65     """GET URL for jolokia"""
66     return "http://" + hostname + ":" + port + \
67         "/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-" + \
68         shardIndex + "-" + shardName + ",type=DistributedConfigDatastore"
69
70
71 # Template for Car init resource payload
72 add_car_init_payload_template = Template(
73     """
74     {"car:cars":{
75         "car-entry": [
76             {
77                 "id": "$id",
78                 "category": "$category",
79                 "model": "$model",
80                 "manufacturer": "$manufacturer",
81                 "year": "$year"
82             }
83         ]
84     }}
85     """)
86
87 # Template for Car resource payload
88 add_car_payload_template = Template(
89     """
90         {"car-entry": [
91             {
92                 "id": "$id",
93                 "category": "$category",
94                 "model": "$model",
95                 "manufacturer": "$manufacturer",
96                 "year": "$year"
97             }
98         ]
99     }
100     """)
101
102 # Template for Person resource payload
103 add_person_payload_template = Template(
104     """
105     {"people:people":{
106         "person": [
107             {
108                 "id": "$personId",
109                 "gender": "$gender",
110                 "age": "$age",
111                 "address": "$address",
112                 "contactNo":"$contactNo"
113             }
114         ]
115     }}
116     """)
117
118 # Template for Car Person mapping  payload
119 add_car_person_template = Template(
120     """
121     {"car-people:car-people":{
122         "car-person": [
123             {
124                 "car-id": "$Id",
125                 "person-id": "$personId"
126             }
127         ]
128     }}
129     """)
130
131 # Template for adding person using RPC
132 add_person_rpc_payload_template = Template(
133     """
134     {
135         "input":
136             {
137                 "people:id" : "$personId",
138                 "people:gender":"$gender",
139                 "people:address" : "$address",
140                 "people:contactNo":"$contactNo",
141                 "people:age":"$age"
142             }
143     }
144     """)
145
146 # Template for buing car rpc
147 buy_car_rpc_template = Template(
148     """
149     {
150         "input" :
151         {
152             "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
153             "car-purchase:person-id" : "$personId",
154             "car-purchase:car-id" : "$carId"
155         }
156     }
157     """)