d98a263219a553ea4b7f0f38cfcbc379cbedcea9
[integration/test.git] / test / csit / libraries / SettingsLibrary.py
1 __author__ = "Basheeruddin Ahmed"
2 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
3 __license__ = "New-style BSD"
4 __email__ = "syedbahm@cisco.com"
5
6 from string import Template
7
8 # helps in taking the hostname entered by the user
9 #global hostname
10 #global port
11
12 #def setHostname(host):
13 #     hostname=host
14
15 #def getServer():
16 #    return hostname +":"+"8080"
17
18 #Cars resource URL for GET
19 def getCarsUrl(hostname,port):
20
21     return "http://"+hostname+":"+port+"/restconf/config/car:cars"
22
23 #People resouce URL for GET
24 def getPersonsUrl(hostname,port):
25
26     return "http://"+hostname+":"+port+"/restconf/config/people:people"
27
28 #GET cars persons mapping resource URL
29 def getCarPersonUrl(hostname,port):
30
31     return "http://"+hostname+":"+port+"/restconf/config/car-people:car-people"
32
33 #POST or DELETE URL
34 def getAddCarUrl(hostname,port):
35     return "http://"+hostname+":"+port+"/restconf/config"
36 #POST or DELETE URL
37 def getAddPersonUrl(hostname,port):
38     return "http://"+hostname+":"+port+"/restconf/config"
39
40 #POST URL -using rpc
41 def getAddPersonRpcUrl(hostname,port):
42     return "http://"+hostname+":"+port+"/restconf/operations/people:add-person"
43
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"
50
51 #GET URL for jolokia
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"
54
55
56 # Template for Car resource payload
57 add_car_payload_template = Template( '{\"car:cars\":{'
58     '\"car-entry\": ['
59         '{'
60             '\"id\": \"$id\",'
61             '\"category\": \"$category\",'
62             '\"model\": \"$model\",'
63             '\"manufacturer\": \"$manufacturer\",'
64             '\"year\": \"$year\"'
65         '}'
66     ']'
67 '}'
68 '}')
69
70 # Template for Person resource payload
71 add_person_payload_template =  Template( '{\"people:people":{'
72     '\"person\": ['
73         '{'
74             '\"id\": \"$personId\",'
75             '\"gender\": \"$gender\",'
76             '\"age\": \"$age\",'
77             '\"address\": \"$address\",'
78             '\"contactNo\":\"$contactNo\"'
79         '}'
80             ']'
81      '}}')
82
83 # Template for Car Person mapping  payload
84 add_car_person_template = Template('{\"car-people:car-people\":{'
85     '\"car-person\": ['
86         '{'
87            ' \"car-id\": \"$Id\",'
88             '\"person-id\": \"$personId\"'
89         '}'
90     ']'
91 '}'
92 '}')
93
94 # Template for adding person using RPC
95 add_person_rpc_payload_template = Template ( '{'
96                                                  '\"input\":'
97                                                      '{'
98                                                          '\"people:id\" : \"$personId\",'
99                                                          '\"people:gender\":\"$gender\",'
100                                                          '\"people:address\" : \"$address\",'
101                                                          '\"people:contactNo\":\"$contactNo\",'
102                                                          '\"people:age\":\"$age\"'
103                                                      '}'
104                                              '}')
105
106 # Template for buing car rpc
107 buy_car_rpc_template = Template ( '{'
108     '\"input\" :'
109         '{'
110             '\"car-purchase:person\" : \"/people:people/people:person[people:id=\'$personId\']\",'
111             '\"car-purchase:person-id\" : \"$personId\",'
112             '\"car-purchase:car-id\" : \"$carId\"'
113         '}'
114 '}')
115
116
117
118
119