7 __author__ = "Jan Medved"
8 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
9 __license__ = "New-style BSD"
10 __email__ = "jmedved@cisco.com"
13 getheaders = {"Accept": "application/json"}
16 def cleanup_config_fl(host, port):
19 url = "http://" + host + ":" + port + "/wm/staticflowentrypusher/clear/all/json"
20 r = requests.get(url, headers=getheaders)
24 def cleanup_config_odl(host, port, auth):
28 "http://" + host + ":" + port + "/restconf/config/opendaylight-inventory:nodes"
32 r = requests.delete(url, headers=getheaders)
34 r = requests.delete(url, headers=getheaders, auth=("admin", "admin"))
39 if __name__ == "__main__":
41 parser = argparse.ArgumentParser(description="Cleans up the config space")
45 help="host where " "odl controller is running (default is 127.0.0.1)",
50 help="port on " "which odl's RESTCONF is listening (default is 8181)",
57 help="Use authenticated access to REST "
58 "(username: 'admin', password: 'admin').",
62 choices=["odl", "floodlight"],
64 help="Controller type (ODL or Floodlight); default odl (OpenDaylight)",
67 in_args = parser.parse_args()
69 if in_args.controller == "odl":
70 sts = cleanup_config_odl(in_args.host, in_args.port, in_args.auth)
72 elif in_args.controller == "floodlight":
73 sts = cleanup_config_fl(in_args.host, in_args.port)
76 print("Unknown controller type")
80 print("Failed to delete nodes in the config space, code %d" % sts)
82 print("Nodes in config space deleted.")