Use last stream release if not specified
[integration/test.git] / tools / odl-mdsal-clustering-tests / replace_cars.py
similarity index 80%
rename from tools/odl-mdsal-clustering-tests/patch_cars_be_sr2.py
rename to tools/odl-mdsal-clustering-tests/replace_cars.py
index 3ae61d14dfba835d972743b6fd4514d02c17fa28..95b008dc54248fc5056b9a7f15da6f7361d84610 100644 (file)
@@ -1,10 +1,8 @@
 """
 The purpose of this script to create enough traffic in config datastore
 to trigger creation of Snapshot.
-This script uses PATCH http method for handling "moving segment" of cars.
+This script uses PUT http method for handling/replacing "moving segment" of cars.
 The car data is minimal, containing only an ID (car-<num>).
-This script is tailored to behavior of Berylium-SR2,
-if the behavior changes, new script will be needed.
 """
 
 
@@ -28,21 +26,11 @@ def main():
       }''')
 
     patch_data_template = string.Template('''{
- "ietf-restconf:yang-patch": {
-  "patch-id": "$ID",
-  "edit": [
-   {
-    "edit-id": "0",
-    "operation": "replace",
-    "target": "/car:car-entry[car:id='0']",
-    "value": {
-     "car:car-entry": [
+ "cars": {
+  "car-entry": [
 $ENTRIES
      ]
     }
-   }
-  ]
- }
 }''')
 
     # Arguments
@@ -70,7 +58,7 @@ $ENTRIES
     # Logic
     url = "http://" + args.host + ':' + args.port + "/restconf/config/car:cars"
     auth = (args.user, args.password)
-    headers = {"Content-Type": "application/yang.patch+json"}
+    headers = {"Content-Type": "application/json"}
     session = requests.Session()
     for iteration in range(args.iterations):
         entry_list = []
@@ -79,10 +67,10 @@ $ENTRIES
             entry_list.append(car_entry_template.substitute({"NUM": str(num_id)}))
         mapping = {"ID": str(iteration), "ENTRIES": ",\n".join(entry_list)}
         data = patch_data_template.substitute(mapping)
-        response = session.patch(url=url, auth=auth, headers=headers, data=data)
+        response = session.put(url=url, auth=auth, headers=headers, data=data)
         if response.status_code not in [200, 201, 204]:
-            print "status:", response.status_code
-            print "text:", response.text
+            print "status: {}".format(response.status_code)
+            print "text: {}".format(response.text)
             sys.exit(1)