1 from string import Template
3 # helps in taking the hostname entered by the user
7 __author__ = "Basheeruddin Ahmed"
8 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
9 __license__ = "New-style BSD"
10 __email__ = "syedbahm@cisco.com"
13 # def setHostname(host):
17 # return hostname +":"+"8080"
20 def getCarsUrl(hostname, port):
21 """Cars resource URL for GET"""
22 return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
25 def getPersonsUrl(hostname, port):
26 """People resouce URL for GET"""
27 return "http://" + hostname + ":" + port + "/restconf/config/people:people"
30 def getCarPersonUrl(hostname, port):
31 """GET cars persons mapping resource URL"""
32 return "http://" + hostname + ":" + port + "/restconf/config/car-people:car-people"
35 def getAddCarInitUrl(hostname, port):
36 """POST or DELETE URL"""
37 return "http://" + hostname + ":" + port + "/restconf/config"
40 def getAddCarUrl(hostname, port):
41 """POST or DELETE URL"""
42 return "http://" + hostname + ":" + port + "/restconf/config/car:cars"
45 def getAddPersonUrl(hostname, port):
46 """POST or DELETE URL"""
47 return "http://" + hostname + ":" + port + "/restconf/config"
50 def getAddPersonRpcUrl(hostname, port):
51 """POST URL -using rpc"""
52 return "http://" + hostname + ":" + port + "/restconf/operations/people:add-person"
55 def getAddCarPersonUrl(hostname, port):
56 """POST URL for car person mapping"""
57 return "http://" + hostname + ":" + port + "/restconf/config"
60 def getBuyCarRpcUrl(hostname, port):
61 """POST URL for buy car rpc"""
63 "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
67 def getJolokiaURL(hostname, port, shardIndex, shardName):
68 """GET URL for jolokia"""
74 + "/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-"
78 + ",type=DistributedConfigDatastore"
82 # Template for Car init resource payload
83 add_car_init_payload_template = Template(
89 "category": "$category",
91 "manufacturer": "$manufacturer",
99 # Template for Car resource payload
100 add_car_payload_template = Template(
105 "category": "$category",
107 "manufacturer": "$manufacturer",
115 # Template for Person resource payload
116 add_person_payload_template = Template(
124 "address": "$address",
125 "contactNo":"$contactNo"
132 # Template for Car Person mapping payload
133 add_car_person_template = Template(
135 {"car-people:car-people":{
139 "person-id": "$personId"
146 # Template for adding person using RPC
147 add_person_rpc_payload_template = Template(
152 "people:id" : "$personId",
153 "people:gender":"$gender",
154 "people:address" : "$address",
155 "people:contactNo":"$contactNo",
162 # Template for buing car rpc
163 buy_car_rpc_template = Template(
168 "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
169 "car-purchase:person-id" : "$personId",
170 "car-purchase:car-id" : "$carId"