init(app): initial version

This commit is contained in:
Aleksandr Tcitlionok
2024-12-04 08:30:25 +00:00
parent 79c3766d06
commit 209bf98fb4
17 changed files with 380 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
# Show pseudo-graphic tables using rich library, if there is no frontend
from rich.console import Console
from rich.table import Table
from database import fetch_all
def display_metal_nodes():
console = Console()
table = Table(title="Metal Nodes")
table.add_column("ID", justify="right")
table.add_column("Name")
table.add_column("Location")
table.add_column("Vendor")
table.add_column("CPU", justify="right")
table.add_column("Memory")
table.add_column("Storage")
nodes = fetch_all("metal_nodes")
for node in nodes:
table.add_row(
str(node[0]), node[1], node[2], node[3],
str(node[4]), node[5], node[6]
)
console.print(table)
def display_virtual_machines():
console = Console()
table = Table(title="Virtual Machines")
table.add_column("ID", justify="right")
table.add_column("Name")
table.add_column("Location")
table.add_column("CPU", justify="right")
table.add_column("Memory")
table.add_column("Storage")
table.add_column("Type")
vms = fetch_all("virtual_machines")
for vm in vms:
table.add_row(
str(vm[0]), vm[1], vm[2],
str(vm[3]), vm[4], vm[5], vm[6]
)
console.print(table)
def display_kubernetes_nodes():
console = Console()
table = Table(title="Kubernetes Nodes")
table.add_column("ID", justify="right")
table.add_column("Cluster Name")
table.add_column("Node Name")
table.add_column("CPU", justify="right")
table.add_column("Memory")
table.add_column("Storage")
table.add_column("Type")
table.add_column("Namespaces")
nodes = fetch_all("kubernetes_nodes")
for node in nodes:
table.add_row(
str(node[0]), node[1], node[2],
str(node[3]), node[4], node[5],
node[6], node[7]
)
console.print(table)
if __name__ == "__main__":
display_metal_nodes()
display_virtual_machines()