Change proportions and add pods' nodes
This commit is contained in:
parent
a702b924d7
commit
6f98dcb010
8
kls
8
kls
|
@ -16,9 +16,9 @@ SCREEN = curses.initscr() # инициализация экрана
|
||||||
execute_cmd = lambda command: subprocess.check_output(command, shell=True).decode().rstrip().split("\n") # вывод команды преобразуем в list
|
execute_cmd = lambda command: subprocess.check_output(command, shell=True).decode().rstrip().split("\n") # вывод команды преобразуем в list
|
||||||
api_resources_top = ["pods", "services", "deployments", "statefulsets", "daemonsets", "ingresses", "configmaps", "secrets", "persistentvolumes", "persistentvolumeclaims", "nodes", "storageclasses"]
|
api_resources_top = ["pods", "services", "deployments", "statefulsets", "daemonsets", "ingresses", "configmaps", "secrets", "persistentvolumes", "persistentvolumeclaims", "nodes", "storageclasses"]
|
||||||
api_resources_kubectl = execute_cmd("kubectl api-resources --no-headers --verbs=get | awk '{print $1}'")
|
api_resources_kubectl = execute_cmd("kubectl api-resources --no-headers --verbs=get | awk '{print $1}'")
|
||||||
MENUS = [Menu("Namespaces", execute_cmd("kubectl get ns --no-headers | awk '{print $1}'"), 0, curses.COLS // 6),
|
MENUS = [Menu("Namespaces", execute_cmd("kubectl get ns --no-headers | awk '{print $1}'"), 0, curses.COLS // 8),
|
||||||
Menu("API resources", api_resources_top + sorted(list(set(api_resources_kubectl) - set(api_resources_top))), curses.COLS // 6, curses.COLS // 4),
|
Menu("API resources", api_resources_top + sorted(list(set(api_resources_kubectl) - set(api_resources_top))), curses.COLS // 8, curses.COLS // 4),
|
||||||
Menu("Resources", [], curses.COLS // 6 + curses.COLS // 4, curses.COLS - (curses.COLS // 6 + curses.COLS // 4))]
|
Menu("Resources", [], curses.COLS // 8 + curses.COLS // 4, curses.COLS - (curses.COLS // 8 + curses.COLS // 4))]
|
||||||
SELECTED_MENU = MENUS[0]
|
SELECTED_MENU = MENUS[0]
|
||||||
HELP_TEXT = "q: exit, /: enter filter mode, Esc: exit filter mode, 1: get yaml, 2: describe, 3: edit, 4: pod logs, arrows/TAB: navigation"
|
HELP_TEXT = "q: exit, /: enter filter mode, Esc: exit filter mode, 1: get yaml, 2: describe, 3: edit, 4: pod logs, arrows/TAB: navigation"
|
||||||
ROWS_NUMBER = curses.LINES - 9 # максимальное число видимых строк меню, начиная с 0
|
ROWS_NUMBER = curses.LINES - 9 # максимальное число видимых строк меню, начиная с 0
|
||||||
|
@ -26,7 +26,7 @@ ROWS_NUMBER = curses.LINES - 9 # максимальное число видим
|
||||||
|
|
||||||
def update_menu3():
|
def update_menu3():
|
||||||
if not MENUS[0].filtered_rows() or not MENUS[1].filtered_rows(): MENUS[2].rows = ["No namespace or API resource selected"]
|
if not MENUS[0].filtered_rows() or not MENUS[1].filtered_rows(): MENUS[2].rows = ["No namespace or API resource selected"]
|
||||||
elif MENUS[1].selected_row() == "pods": MENUS[2].rows = execute_cmd(f"kubectl -n {MENUS[0].selected_row()} get pods --no-headers | awk '{{ printf \"%-65s %-20s\\n\", $1,$3 }}'")
|
elif MENUS[1].selected_row() == "pods": MENUS[2].rows = execute_cmd(f"kubectl -n {MENUS[0].selected_row()} get pods -o wide --no-headers | awk '{{ printf \"%-65s %-16s %-10s\\n\", $1,$3,$(NF - 2) }}'")
|
||||||
else: MENUS[2].rows = execute_cmd(f"kubectl -n {MENUS[0].selected_row()} get {MENUS[1].selected_row()} --no-headers | awk '{{printf \"%-85s\\n\", $1}}'")
|
else: MENUS[2].rows = execute_cmd(f"kubectl -n {MENUS[0].selected_row()} get {MENUS[1].selected_row()} --no-headers | awk '{{printf \"%-85s\\n\", $1}}'")
|
||||||
if MENUS[2].rows == ['']: MENUS[2].rows = [f"No {MENUS[1].selected_row()} found in {MENUS[0].selected_row()} namespace."]
|
if MENUS[2].rows == ['']: MENUS[2].rows = [f"No {MENUS[1].selected_row()} found in {MENUS[0].selected_row()} namespace."]
|
||||||
MENUS[2].selected_row_index = 0 # перед перерисовкой сбрасываем выбранную строку на 0
|
MENUS[2].selected_row_index = 0 # перед перерисовкой сбрасываем выбранную строку на 0
|
||||||
|
|
Loading…
Reference in New Issue