1 __author__ = "Basheeruddin Ahmed"
2 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
3 __license__ = "New-style BSD"
4 __email__ = "syedbahm@cisco.com"
6 from string import Template
8 # helps in taking the hostname entered by the user
12 # def setHostname(host):
16 # return hostname +":"+"8080"
19 def getCarsUrl(hostname, port):
20 """Cars resource URL for GET"""
21 return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
24 def getPersonsUrl(hostname, port):
25 """People resouce URL for GET"""
26 return "http://" + hostname + ":" + port + "/restconf/config/people:people"
29 def getCarPersonUrl(hostname, port):
30 """GET cars persons mapping resource URL"""
31 return "http://" + hostname + ":" + port + "/restconf/config/car-people:car-people"
34 def getAddCarInitUrl(hostname, port):
35 """POST or DELETE URL"""
36 return "http://" + hostname + ":" + port + "/restconf/config"
39 def getAddCarUrl(hostname, port):
40 """POST or DELETE URL"""
41 return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
44 def getAddPersonUrl(hostname, port):
45 """POST or DELETE URL"""
46 return "http://" + hostname + ":" + port + "/restconf/config"
49 def getAddPersonRpcUrl(hostname, port):
50 """POST URL -using rpc"""
51 return "http://" + hostname + ":" + port + "/restconf/operations/people:add-person"
54 def getAddCarPersonUrl(hostname, port):
55 """POST URL for car person mapping"""
56 return "http://" + hostname + ":" + port + "/restconf/config"
59 def getBuyCarRpcUrl(hostname, port):
60 """POST URL for buy car rpc"""
61 return "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
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"
71 # Template for Car init resource payload
72 add_car_init_payload_template = Template(
78 "category": "$category",
80 "manufacturer": "$manufacturer",
87 # Template for Car resource payload
88 add_car_payload_template = Template(
93 "category": "$category",
95 "manufacturer": "$manufacturer",
102 # Template for Person resource payload
103 add_person_payload_template = Template(
111 "address": "$address",
112 "contactNo":"$contactNo"
118 # Template for Car Person mapping payload
119 add_car_person_template = Template(
121 {"car-people:car-people":{
125 "person-id": "$personId"
131 # Template for adding person using RPC
132 add_person_rpc_payload_template = Template(
137 "people:id" : "$personId",
138 "people:gender":"$gender",
139 "people:address" : "$address",
140 "people:contactNo":"$contactNo",
146 # Template for buing car rpc
147 buy_car_rpc_template = Template(
152 "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
153 "car-purchase:person-id" : "$personId",
154 "car-purchase:car-id" : "$carId"