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"""
62 return "http://" + hostname + ":" + port + "/restconf/operations/car-purchase:buy-car"
65 def getJolokiaURL(hostname, port, shardIndex, shardName):
66 """GET URL for jolokia"""
67 return "http://" + hostname + ":" + port + \
68 "/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-" + \
69 shardIndex + "-" + shardName + ",type=DistributedConfigDatastore"
72 # Template for Car init resource payload
73 add_car_init_payload_template = Template(
79 "category": "$category",
81 "manufacturer": "$manufacturer",
88 # Template for Car resource payload
89 add_car_payload_template = Template(
94 "category": "$category",
96 "manufacturer": "$manufacturer",
103 # Template for Person resource payload
104 add_person_payload_template = Template(
112 "address": "$address",
113 "contactNo":"$contactNo"
119 # Template for Car Person mapping payload
120 add_car_person_template = Template(
122 {"car-people:car-people":{
126 "person-id": "$personId"
132 # Template for adding person using RPC
133 add_person_rpc_payload_template = Template(
138 "people:id" : "$personId",
139 "people:gender":"$gender",
140 "people:address" : "$address",
141 "people:contactNo":"$contactNo",
147 # Template for buing car rpc
148 buy_car_rpc_template = Template(
153 "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
154 "car-purchase:person-id" : "$personId",
155 "car-purchase:car-id" : "$carId"