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 getAddCarUrl(hostname, port):
35 """POST or DELETE URL"""
36 return "http://" + hostname + ":" + port + "/restconf/config"
39 def getAddPersonUrl(hostname, port):
40 """POST or DELETE URL"""
41 return "http://" + hostname + ":" + port + "/restconf/config"
44 def getAddPersonRpcUrl(hostname, port):
45 """POST URL -using rpc"""
46 return "http://" + hostname + ":" + port + "/restconf/operations/people:add-person"
49 def getAddCarPersonUrl(hostname, port):
50 """POST URL for car person mapping"""
51 return "http://" + hostname + ":" + port + "/restconf/config"
54 def getBuyCarRpcUrl(hostname, port):
55 """POST URL for buy car rpc"""
56 return "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
59 def getJolokiaURL(hostname, port, shardIndex, shardName):
60 """GET URL for jolokia"""
61 return "http://" + hostname + ":" + port + \
62 "/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-" + \
63 shardIndex + "-" + shardName + ",type=DistributedConfigDatastore"
66 # Template for Car resource payload
67 add_car_payload_template = Template(
73 "category": "$category",
75 "manufacturer": "$manufacturer",
82 # Template for Person resource payload
83 add_person_payload_template = Template(
91 "address": "$address",
92 "contactNo":"$contactNo"
98 # Template for Car Person mapping payload
99 add_car_person_template = Template(
101 {"car-people:car-people":{
105 "person-id": "$personId"
111 # Template for adding person using RPC
112 add_person_rpc_payload_template = Template(
117 "people:id" : "$personId",
118 "people:gender":"$gender",
119 "people:address" : "$address",
120 "people:contactNo":"$contactNo",
126 # Template for buing car rpc
127 buy_car_rpc_template = Template(
132 "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
133 "car-purchase:person-id" : "$personId",
134 "car-purchase:car-id" : "$carId"