From 91e916aee403321525233d748e8703b025cd2857 Mon Sep 17 00:00:00 2001 From: "matthias.gatto" Date: Thu, 23 Nov 2023 17:49:53 +0100 Subject: [PATCH] add route tables but only show id for now Signed-off-by: matthias.gatto --- osc_tui/mainForm.py | 7 +++++-- osc_tui/routeTables.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 osc_tui/routeTables.py diff --git a/osc_tui/mainForm.py b/osc_tui/mainForm.py index 9bd704f..13955dc 100644 --- a/osc_tui/mainForm.py +++ b/osc_tui/mainForm.py @@ -33,6 +33,7 @@ from osc_tui import nicsGrid from osc_tui import publicIps from osc_tui import internetServices +from osc_tui import routeTables from osc_diagram import osc_diagram @@ -61,7 +62,7 @@ def swicthToVolumeLink(self, id, volume): # update draw_line_at when adding a new resource class mainMenu(oscscreen.MultiLineAction): - def __init__(self, screen, form=None, draw_line_at=15, *args, **keywords): + def __init__(self, screen, form=None, draw_line_at=16, *args, **keywords): super().__init__(screen, *args, **keywords) self.form = form self.cursor_line = SELECTED_BUTTON @@ -256,7 +257,7 @@ def build_line(size): out = out + '‎' return out menu_desc = ( - "Vms Security Volumes Snapshots Keypairs Images LoadBalancers Nets Subnets PublicIps Nics NetAccessPoints NetPeering InternetServices GPUs " + build_line(15) + " Refresh Quit").split() + "Vms Security Volumes Snapshots Keypairs Images LoadBalancers Nets Subnets PublicIps Nics NetAccessPoints NetPeering InternetServices RouteTables GPUs " + build_line(15) + " Refresh Quit").split() global CURRENT_GRID_CLASS y, _ = self.useable_space() self.rowOffset = MENU_WIDTH @@ -312,6 +313,8 @@ def build_line(size): CURRENT_GRID_CLASS = nicsGrid.nicsGrid elif MODE == 'InternetServices': CURRENT_GRID_CLASS = internetServices.internetServicesGrid + elif MODE == 'RouteTables': + CURRENT_GRID_CLASS = routeTables.routeTablesGrid elif MODE == 'PublicIps': CURRENT_GRID_CLASS = publicIps.publicIpsGrid elif MODE == 'Keypairs': diff --git a/osc_tui/routeTables.py b/osc_tui/routeTables.py new file mode 100644 index 0000000..53d06a8 --- /dev/null +++ b/osc_tui/routeTables.py @@ -0,0 +1,19 @@ +from osc_tui import main +from osc_tui import popup +from osc_tui import selectableGrid + +class routeTablesGrid(selectableGrid.SelectableGrid): + def __init__(self, screen, *args, **keywords): + super().__init__(screen, *args, **keywords) + self.col_titles = ["Id"] + + def refresh_call(self, name_filter=None): + groups = main.GATEWAY.ReadRouteTables(form=self.form)['RouteTables'] + return groups + + def refresh(self): + groups = main.do_search(self.data.copy(), ["RouteTableId"]) + values = list() + for g in groups: + values.append([g['RouteTableId']]) + self.values = values