mirror of
https://github.com/OVERLORD7F/SVMU.git
synced 2025-10-01 21:52:47 +03:00
- Finally, proper config file is here!
- Small changes in menus
This commit is contained in:
28
main.py
28
main.py
@@ -4,11 +4,10 @@ from cluster_api import *
|
||||
from domain_api import *
|
||||
from data_pools_api import *
|
||||
from disk_edit_mode import *
|
||||
from rich import print
|
||||
from rich.panel import Panel
|
||||
from rich.console import Console , Align
|
||||
|
||||
config_relative_path = os.path.join(os.getcwd() , 'config.txt') #config.txt in the same directory with main.py
|
||||
config_relative_path = os.path.join(os.getcwd() , 'SpaceVM_Utility.conf') #config.txt in the same directory with main.py
|
||||
if os.path.exists(config_relative_path) and os.path.getsize(config_relative_path) > 0: #check if config exists and not empty
|
||||
pass #do nothing
|
||||
else:
|
||||
@@ -16,22 +15,35 @@ else:
|
||||
config_edit(config_relative_path)
|
||||
|
||||
#importing API-KEY / IP / DATA POOL UUID / VM-UUIDs from config
|
||||
#base_url=threelines[0] api_key=threelines[1] data_pool_uuid=threelines[2]
|
||||
base_url, api_key, data_pool_uuid = import_threelines(config_relative_path)
|
||||
vm_uuids = import_vm_uuid(config_relative_path)
|
||||
config_data = config_import(config_relative_path)
|
||||
|
||||
base_url = config_data['base_url']
|
||||
api_key = config_data['api_key']
|
||||
data_pool_uuid = config_data['data_pool_uuid']
|
||||
vm_uuids = config_data['vm_list']
|
||||
data_pool_name = get_data_pool_name(base_url , api_key , data_pool_uuid)
|
||||
|
||||
#for x in vm_uuids:
|
||||
# vm_names = get_vm_name(base_url , api_key , x)
|
||||
# print(vm_names)
|
||||
|
||||
|
||||
menu_choice=0
|
||||
menu_options="[gold bold][1] [grey53 italic]Manage utility config\n[/grey53 italic] \
|
||||
menu_options=f"[gold bold][1] [grey53 italic]Manage utility config\n[/grey53 italic] \
|
||||
\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 \
|
||||
\n[gold bold][4] [grey53 italic]Show VM info \n (for selected VMs in config)[/grey53 italic]\n \
|
||||
\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 \
|
||||
\n\n[green_yellow bold]ENTER - exit Utility"
|
||||
\n\n[green_yellow bold]ENTER - exit Utility\n\n \
|
||||
[grey53]Connected to Controller: {base_url} \n Selected Data Pool: {data_pool_name} \n Selected VMs:\n {vm_uuids}"
|
||||
|
||||
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 = Console()
|
||||
os.system('cls' if os.name=='nt' else 'clear')
|
||||
#os.system('cls' if os.name=='nt' else 'clear')
|
||||
while(menu_choice != ""): #main menu loop
|
||||
console.print(Panel(menu_options,
|
||||
title="[bold magenta]SpaceVM Utility - Main Menu" , subtitle = menu_subtitle, subtitle_align="right" , style="yellow" , width=150 , padding = 2))
|
||||
|
Reference in New Issue
Block a user