mirror of
https://github.com/OVERLORD7F/SVMU.git
synced 2025-10-01 21:52:47 +03:00
Added options in config for courses #16
This commit is contained in:
@@ -51,13 +51,19 @@ def config_import(config_relative_path):
|
|||||||
if 'VM_List' in config:
|
if 'VM_List' in config:
|
||||||
for key, value in config['VM_List'].items():
|
for key, value in config['VM_List'].items():
|
||||||
vm_list.append(value)
|
vm_list.append(value)
|
||||||
|
|
||||||
|
#importing disk sizes for SpaceVM courses
|
||||||
|
disk1_size = config.get('Courses-Space-VM', 'disk1')
|
||||||
|
disk2_size = config.get('Courses-Space-VM', 'disk2')
|
||||||
|
disk3_size = config.get('Courses-Space-VM', 'disk3')
|
||||||
|
|
||||||
#get pretty name for selected data pool
|
#get pretty name for selected data pool
|
||||||
data_pool_name = get_data_pool_name(base_url , api_key , data_pool_uuid)
|
data_pool_name = get_data_pool_name(base_url , api_key , data_pool_uuid)
|
||||||
#get pretty name for selected VMs
|
#get pretty name for selected VMs
|
||||||
vm_names=[]
|
vm_names=[]
|
||||||
for x in vm_list:
|
for x in vm_list:
|
||||||
vm_names.append(get_vm_name(base_url, api_key, x))
|
vm_names.append(get_vm_name(base_url, api_key, x))
|
||||||
return base_url, api_key, data_pool_uuid, data_pool_name, vm_list, vm_names
|
return base_url, api_key, data_pool_uuid, data_pool_name, vm_list, vm_names, disk1_size, disk2_size, disk3_size
|
||||||
|
|
||||||
def change_data_pool(base_url, api_key, config_relative_path):
|
def change_data_pool(base_url, api_key, config_relative_path):
|
||||||
cls()
|
cls()
|
||||||
|
@@ -4,7 +4,7 @@ from domain_api import *
|
|||||||
from rich.prompt import Prompt
|
from rich.prompt import Prompt
|
||||||
from rich.console import Console , Align
|
from rich.console import Console , Align
|
||||||
|
|
||||||
def disk_edit_mode(base_url , api_key , data_pool_uuid , vm_uuids):
|
def disk_edit_mode(base_url , api_key , data_pool_uuid , vm_uuids, disk1_size, disk2_size, disk3_size):
|
||||||
os.system('cls' if os.name=='nt' else 'clear')
|
os.system('cls' if os.name=='nt' else 'clear')
|
||||||
diks_edit_menu_options="[gold bold][1] [grey53 italic]Delete vDisk by UUID\n[/grey53 italic] \
|
diks_edit_menu_options="[gold bold][1] [grey53 italic]Delete vDisk by UUID\n[/grey53 italic] \
|
||||||
\n[gold bold][2] [grey53 italic]Delete ALL vDisks on selected Virtual Machine[/grey53 italic]\n \
|
\n[gold bold][2] [grey53 italic]Delete ALL vDisks on selected Virtual Machine[/grey53 italic]\n \
|
||||||
@@ -55,13 +55,13 @@ def disk_edit_mode(base_url , api_key , data_pool_uuid , vm_uuids):
|
|||||||
for z in vm_uuids: # only for creating disks
|
for z in vm_uuids: # only for creating disks
|
||||||
domain_uuid = z.strip('\n')
|
domain_uuid = z.strip('\n')
|
||||||
vm_name = get_vm_name(base_url, api_key, domain_uuid)
|
vm_name = get_vm_name(base_url, api_key, domain_uuid)
|
||||||
console.print(f"\n[bold underline yellow]Creating and attaching disk to VM {vm_name}")
|
console.print(f"\n[bold underline yellow]Creating and attaching disk to[/] [bright_cyan]{vm_name}:")
|
||||||
domain_info = get_domain_info(base_url , api_key , domain_uuid)
|
domain_info = get_domain_info(base_url , api_key , domain_uuid)
|
||||||
domain_all_content = get_domain_all_content(base_url , api_key , domain_uuid)
|
domain_all_content = get_domain_all_content(base_url , api_key , domain_uuid)
|
||||||
if domain_info:
|
if domain_info:
|
||||||
create_and_attach_disk(base_url , api_key , domain_uuid , data_pool_uuid, 10, "falloc")
|
create_and_attach_disk(base_url , api_key , domain_uuid , data_pool_uuid, disk1_size, "falloc")
|
||||||
create_and_attach_disk(base_url , api_key , domain_uuid , data_pool_uuid, 20, "falloc")
|
create_and_attach_disk(base_url , api_key , domain_uuid , data_pool_uuid, disk2_size, "falloc")
|
||||||
create_and_attach_disk(base_url , api_key , domain_uuid , data_pool_uuid, 20, "falloc")
|
create_and_attach_disk(base_url , api_key , domain_uuid , data_pool_uuid, disk3_size, "falloc")
|
||||||
console.print("[bold green]\nDone. Happy virtualization :thumbs_up::thumbs_up:")
|
console.print("[bold green]\nDone. Happy virtualization :thumbs_up::thumbs_up:")
|
||||||
Prompt.ask("[green_yellow bold]ENTER - return to Main Menu.. :right_arrow_curving_down:")
|
Prompt.ask("[green_yellow bold]ENTER - return to Main Menu.. :right_arrow_curving_down:")
|
||||||
os.system('cls' if os.name=='nt' else 'clear')
|
os.system('cls' if os.name=='nt' else 'clear')
|
4
main.py
4
main.py
@@ -18,7 +18,7 @@ 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
|
while(menu_choice != ""): #main menu loop
|
||||||
check_config(config_relative_path)
|
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
|
base_url, api_key, data_pool_uuid, data_pool_name, vm_uuids, vm_names, disk1_size, disk2_size, disk3_size = 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] \
|
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][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][3] [grey53 italic]Show breif cluster overview[/grey53 italic]\n \
|
||||||
@@ -35,7 +35,7 @@ while(menu_choice != ""): #main menu loop
|
|||||||
if menu_choice == "1":
|
if menu_choice == "1":
|
||||||
config_menu(base_url, api_key, config_relative_path)
|
config_menu(base_url, api_key, config_relative_path)
|
||||||
if menu_choice == "2":
|
if menu_choice == "2":
|
||||||
disk_edit_mode(base_url , api_key , data_pool_uuid , vm_uuids)
|
disk_edit_mode(base_url , api_key , data_pool_uuid , vm_uuids, disk1_size, disk2_size, disk3_size)
|
||||||
if menu_choice == "3":
|
if menu_choice == "3":
|
||||||
cluster_info(base_url , api_key)
|
cluster_info(base_url , api_key)
|
||||||
if menu_choice == "4":
|
if menu_choice == "4":
|
||||||
|
Reference in New Issue
Block a user