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"
18 #Cars resource URL for GET
19 def getCarsUrl(hostname,port):
21 return "http://"+hostname+":"+port+"/restconf/config/car:cars"
23 #People resouce URL for GET
24 def getPersonsUrl(hostname,port):
26 return "http://"+hostname+":"+port+"/restconf/config/people:people"
28 #GET cars persons mapping resource URL
29 def getCarPersonUrl(hostname,port):
31 return "http://"+hostname+":"+port+"/restconf/config/car-people:car-people"
34 def getAddCarUrl(hostname,port):
35 return "http://"+hostname+":"+port+"/restconf/config"
37 def getAddPersonUrl(hostname,port):
38 return "http://"+hostname+":"+port+"/restconf/config"
41 def getAddPersonRpcUrl(hostname,port):
42 return "http://"+hostname+":"+port+"/restconf/operations/people:add-person"
44 #POST URL for car person mapping
45 def getAddCarPersonUrl(hostname,port):
46 return "http://"+hostname+":"+port+"/restconf/config"
47 #POST URL for buy car rpc
48 def getBuyCarRpcUrl(hostname,port):
49 return "http://"+hostname+":"+port+"/restconf/operations/car-purchase:buy-car"
52 def getJolokiaURL(hostname,port, shardIndex,shardName):
53 return "http://"+ hostname + ":"+ port+"/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-"+shardIndex+"-"+shardName+",type=DistributedConfigDatastore"
56 # Template for Car resource payload
57 add_car_payload_template = Template( '{\"car:cars\":{'
61 '\"category\": \"$category\",'
62 '\"model\": \"$model\",'
63 '\"manufacturer\": \"$manufacturer\",'
70 # Template for Person resource payload
71 add_person_payload_template = Template( '{\"people:people":{'
74 '\"id\": \"$personId\",'
75 '\"gender\": \"$gender\",'
77 '\"address\": \"$address\",'
78 '\"contactNo\":\"$contactNo\"'
83 # Template for Car Person mapping payload
84 add_car_person_template = Template('{\"car-people:car-people\":{'
87 ' \"car-id\": \"$Id\",'
88 '\"person-id\": \"$personId\"'
94 # Template for adding person using RPC
95 add_person_rpc_payload_template = Template ( '{'
98 '\"people:id\" : \"$personId\",'
99 '\"people:gender\":\"$gender\",'
100 '\"people:address\" : \"$address\",'
101 '\"people:contactNo\":\"$contactNo\",'
102 '\"people:age\":\"$age\"'
106 # Template for buing car rpc
107 buy_car_rpc_template = Template ( '{'
110 '\"car-purchase:person\" : \"/people:people/people:person[people:id=\'$personId\']\",'
111 '\"car-purchase:person-id\" : \"$personId\",'
112 '\"car-purchase:car-id\" : \"$carId\"'