2025-05-12 17:21:00 +03:00
import os
2025-05-15 11:51:06 +03:00
from config_data_import import *
2025-05-12 17:21:00 +03:00
from cluster_api import *
from domain_api import *
2025-05-13 17:41:42 +03:00
from data_pools_api import *
2025-05-16 12:17:51 +03:00
from disk_edit_mode import *
2025-05-16 17:53:57 +03:00
from rich . panel import Panel
from rich . console import Console , Align
2025-05-07 16:20:36 +03:00
2025-05-28 12:45:07 +03:00
config_relative_path = os . path . join ( os . getcwd ( ) , ' SpaceVM_Utility.conf ' ) #config.txt in the same directory with main.py
2025-05-12 17:21:00 +03:00
2025-05-16 17:53:57 +03:00
menu_choice = 0
2025-05-28 12:45:07 +03:00
console = Console ( )
os . system ( ' cls ' if os . name == ' nt ' else ' clear ' )
while ( menu_choice != " " ) : #main menu loop
check_config ( config_relative_path )
base_url , api_key , data_pool_uuid , data_pool_name , vm_uuids , vm_names = config_import ( config_relative_path ) #importing API-KEY / IP / DATA POOL UUID / VM-UUIDs from config
menu_options = f " [gold bold][1] [grey53 italic]Manage utility config \n [/grey53 italic] \
2025-05-16 17:53:57 +03:00
\n [ gold bold ] [ 2 ] [ grey53 italic ] Enter disk edit mode [ / grey53 italic ] \n \
\n [ gold bold ] [ 3 ] [ grey53 italic ] Show breif cluster overview [ / grey53 italic ] \n \
2025-05-21 14:12:37 +03:00
\n [ gold bold ] [ 4 ] [ grey53 italic ] Show VM info \n ( for selected VMs in config ) [ / grey53 italic ] \n \
2025-05-16 17:53:57 +03:00
\n [ gold bold ] [ 5 ] [ grey53 italic ] Show data pools [ / grey53 italic ] \n \
\n [ gold bold ] [ 6 ] [ grey53 italic ] Show VMs Name / UUID [ / grey53 italic ] \n \
2025-05-28 12:45:07 +03:00
\n \n [ green_yellow bold ] ENTER - exit Utility [ / ] \n \n \
[ underline bold grey53 ] Currently imported config : [ / ] \n \
[ bold grey53 ] Connected to Controller : [ bright_yellow ] { base_url } [ / ] \n Selected Data Pool : [ bright_yellow ] { data_pool_name } [ / ] \n Selected VMs : \n [ bright_yellow ] { vm_names } "
menu_options = Align . center ( menu_options , vertical = " middle " )
menu_subtitle = " [blue bold][link=https://github.com/OVERLORD7F/SpaceVM_VM_Utility]:wrench: Project_GitHub[/link] [yellow]| [magenta bold][link=https://spacevm.ru/docs/]:books: SpaceVM_Docs[/link] [yellow]| [red bold][link=https://comptek.ru]:briefcase: Comptek[/link] "
console . print ( Panel ( menu_options , title = " [bold magenta]SpaceVM Utility - Main Menu " , subtitle = menu_subtitle , subtitle_align = " right " , style = " yellow " , width = 150 , padding = 2 ) )
2025-05-15 15:41:33 +03:00
menu_choice = str ( input ( " \n >>> " ) )
2025-05-07 16:20:36 +03:00
if menu_choice == " 1 " :
2025-05-16 12:17:51 +03:00
config_menu ( config_relative_path )
2025-05-15 10:21:48 +03:00
if menu_choice == " 2 " :
2025-05-16 12:17:51 +03:00
disk_edit_mode ( base_url , api_key , data_pool_uuid , vm_uuids )
2025-05-07 16:20:36 +03:00
if menu_choice == " 3 " :
2025-05-12 17:21:00 +03:00
cluster_info ( base_url , api_key )
2025-05-07 16:20:36 +03:00
if menu_choice == " 4 " :
2025-05-21 14:12:37 +03:00
os . system ( ' cls ' if os . name == ' nt ' else ' clear ' )
2025-05-07 16:20:36 +03:00
for x in vm_uuids :
2025-05-12 17:21:00 +03:00
vm_info ( base_url , api_key , x )
2025-05-21 14:12:37 +03:00
Prompt . ask ( " [green_yellow bold]Press ENTER to proceed.. :right_arrow_curving_down: " )
2025-05-13 17:41:42 +03:00
if menu_choice == " 5 " :
2025-05-28 12:45:07 +03:00
show_data_pools ( base_url , api_key )
2025-05-15 11:51:06 +03:00
if menu_choice == " 6 " :
2025-05-21 14:12:37 +03:00
vm_info_short ( base_url , api_key )
2025-05-26 10:28:01 +03:00
if menu_choice == " 7 " :
check_api_key ( base_url , api_key )
2025-05-21 14:12:37 +03:00
os . system ( ' cls ' if os . name == ' nt ' else ' clear ' ) #clears screen before looping back to main menu
2025-05-28 12:45:07 +03:00
console . print ( " [red bold]Exiting Utility " )