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 # Template for Car resource payload
53 add_car_payload_template = Template( '{\"car:cars\":{'
57 '\"category\": \"$category\",'
58 '\"model\": \"$model\",'
59 '\"manufacturer\": \"$manufacturer\",'
66 # Template for Person resource payload
67 add_person_payload_template = Template( '{\"people:people":{'
70 '\"id\": \"$personId\",'
71 '\"gender\": \"$gender\",'
73 '\"address\": \"$address\",'
74 '\"contactNo\":\"$contactNo\"'
79 # Template for Car Person mapping payload
80 add_car_person_template = Template('{\"car-people:car-people\":{'
83 ' \"car-id\": \"$Id\",'
84 '\"person-id\": \"$personId\"'
90 # Template for adding person using RPC
91 add_person_rpc_payload_template = Template ( '{'
94 '\"people:id\" : \"$personId\",'
95 '\"people:gender\":\"$gender\",'
96 '\"people:address\" : \"$address\",'
97 '\"people:contactNo\":\"$contactNo\",'
98 '\"people:age\":\"$age\"'
102 # Template for buing car rpc
103 buy_car_rpc_template = Template ( '{'
106 '\"car-purchase:person\" : \"/people:people/people:person[people:id=\'$personId\']\",'
107 '\"car-purchase:person-id\" : \"$personId\",'
108 '\"car-purchase:car-id\" : \"$carId\"'