From 2cadb84f4c4bd734bba46ffd2ac957f130ef7fcc Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 10 Jul 2020 12:01:58 -0700 Subject: [PATCH] Added methods to Realm to remove all stations, endps, or cxs --- py-json/realm.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/py-json/realm.py b/py-json/realm.py index 446ec692..7b470978 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -265,6 +265,51 @@ class Realm(LFCliBase): raise ValueError("time_string must be of type str. Type %s provided" % type(time_string)) return duration_time + def remove_all_stations(self, resource): + port_list = self.station_list() + sta_list = [] + if sta_list is not None: + print("Removing all stations") + for item in list(port_list): + if "sta" in list(item)[0]: + sta_list.append(self.name_to_eid(list(item)[0])[2]) + + for sta_name in sta_list: + req_url = "cli-json/rm_vlan" + data = { + "shelf": 1, + "resource": resource, + "port": sta_name + } + self.json_post(req_url, data) + + def remove_all_endps(self): + endp_list = self.json_get("/endp") + if endp_list is not None: + print("Removing all endps") + endp_list = list(endp_list['endpoint']) + for endp_name in range(len(endp_list)): + name = list(endp_list[endp_name])[0] + req_url = "cli-json/rm_endp" + data = { + "endp_name": name + } + self.json_post(req_url, data) + + def remove_all_cxs(self): + cx_list = list(self.cx_list()) + not_cx = ['warnings', 'errors', 'handler', 'uri', 'items'] + if cx_list is not None: + print("Removing all cxs") + for cx_name in cx_list: + if cx_name in not_cx: + continue + req_url = "cli-json/rm_cx" + data = { + "test_mgr": "default_tm", + "cx_name": cx_name + } + self.json_post(req_url, data) def parse_link(self, link): link = self.lfclient_url + link