mirror of
https://github.com/OVERLORD7F/SVMU.git
synced 2025-10-01 21:52:47 +03:00
- Changed "disk edit mode" into function and moved to new module
- Changed config sub menu into function and moved to config_data_import module - New function config_show - Fixed create disk option in disk edit mode - A few formatting changes in menus
This commit is contained in:
58
disk_edit_mode.py
Normal file
58
disk_edit_mode.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import os
|
||||
import requests
|
||||
from domain_api import *
|
||||
|
||||
def disk_edit_mode(base_url , api_key , data_pool_uuid , vm_uuids):
|
||||
print("\033[H\033[2J", end="")
|
||||
print("### DISK EDIT MODE ###\n")
|
||||
print("1) Delete vDisk by UUID")
|
||||
print("2) Delete ALL vDisks on selected Virtual Machine")
|
||||
print("3) Create Disk")
|
||||
print("4) Prepare VMs for Courses™")
|
||||
print("\nENTER - return to Utility Main Menu ")
|
||||
sub_choice=str(input("\n>>> "))
|
||||
if sub_choice == "1":
|
||||
read_input=input("Input vDisk uuid to delete: ")
|
||||
vdisk_uuid=str(read_input)
|
||||
delete_disk(base_url , api_key , vdisk_uuid)
|
||||
|
||||
if sub_choice == "2":
|
||||
print(vm_uuids)
|
||||
select_uuids=int(input("Select VM to delete disks from. \n Type VM uuid index number (from list above) to select: ")) - 1
|
||||
vm_check_power(base_url , api_key , vm_uuids[select_uuids]) #power on check
|
||||
domain_all_content = get_domain_all_content(base_url , api_key , vm_uuids[select_uuids])
|
||||
disk_uuids = get_disk_uuids(base_url , api_key , domain_all_content)
|
||||
for x in disk_uuids:
|
||||
delete_disk(base_url , api_key , x)
|
||||
print("All attached vDisks has been deleted!")
|
||||
|
||||
if sub_choice == "3":
|
||||
vdisk_size=str(input("Enter disk size (GB): "))
|
||||
print(vm_uuids)
|
||||
select_uuids=int(input("Select VM to attach new disk. \n Type VM uuid index number (from list above) to select: ")) - 1
|
||||
print(f"{vm_uuids[select_uuids]} - {data_pool_uuid} - {vdisk_size} ")
|
||||
create_and_attach_disk(base_url , api_key , vm_uuids[select_uuids] , data_pool_uuid , vdisk_size , "falloc")
|
||||
|
||||
if sub_choice == "4":
|
||||
print("#" * 5 , "Preparing VMs for Courses" , "#" * 5)
|
||||
for y in vm_uuids: #power-on check
|
||||
domain_uuid = y.strip('\n')
|
||||
vm_check_power(base_url , api_key , domain_uuid)
|
||||
for x in vm_uuids: # only for removing disks
|
||||
domain_uuid = x.strip('\n')
|
||||
domain_info = get_domain_info(base_url , api_key , domain_uuid)
|
||||
domain_all_content = get_domain_all_content(base_url , api_key , domain_uuid)
|
||||
vm_info(base_url , api_key , domain_uuid)
|
||||
if domain_info:
|
||||
disk_uuids = get_disk_uuids(base_url , api_key , domain_all_content)
|
||||
for y in disk_uuids:
|
||||
delete_disk(base_url , api_key , y)
|
||||
print("All attached vDisks has been deleted!")
|
||||
for z in vm_uuids: # only for creating disks
|
||||
domain_uuid = z.strip('\n')
|
||||
domain_info = get_domain_info(base_url , api_key , domain_uuid)
|
||||
domain_all_content = get_domain_all_content(base_url , api_key , domain_uuid)
|
||||
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, 20, "falloc")
|
||||
create_and_attach_disk(base_url , api_key , domain_uuid , data_pool_uuid, 20, "falloc")
|
Reference in New Issue
Block a user