mirror of
https://github.com/OVERLORD7F/SVMU.git
synced 2025-10-01 21:52:47 +03:00
Merge branch 'main' of https://github.com/OVERLORD7F/SpaceVM_VM_Utility
This commit is contained in:
29
README.md
29
README.md
@@ -7,18 +7,31 @@ _For now, this utility is focused on managing virtual disks_
|
|||||||
|
|
||||||
_Works with SpaceVM 6.5.5+_
|
_Works with SpaceVM 6.5.5+_
|
||||||
|
|
||||||
# Config File
|
# Utility usage
|
||||||
|
Clone repository or use compiled .exe
|
||||||
|
|
||||||
|
Config file is essential for the utility.
|
||||||
|
|
||||||
|
## Config File
|
||||||
Config file contains all necessary data for utility and has to be placed in the same directory as Utility itself.
|
Config file contains all necessary data for utility and has to be placed in the same directory as Utility itself.
|
||||||
|
|
||||||
|
<ins>The following parameters are required:</ins>
|
||||||
|
```
|
||||||
|
1. Controller IP Address (Master)
|
||||||
|
2. API Integration Key
|
||||||
|
3. Data Pool UUID (which will be used for operations)
|
||||||
|
4. Virtual Machine UUID (List of selected VMs for operations)
|
||||||
|
5. Virtual Machine UUID
|
||||||
|
6. ...
|
||||||
|
```
|
||||||
|
|
||||||
You can populate config within Utility Main Menu.
|
You can populate config within Utility Main Menu.
|
||||||
|
|
||||||
For manual input see format below:
|
For manual input see format below:
|
||||||
```
|
```
|
||||||
Controller IP Address
|
1.2.3.4
|
||||||
API Integration Key
|
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1...
|
||||||
Data Pool UUID
|
67497424-e54b-46f1-b023-4d6d65eac104
|
||||||
VM UUID #1
|
304fd7be-06a6-4f4e-9bb9-41bf532ec4fb
|
||||||
VM UUID #2
|
f840320f-cecc-4a31-a799-fd84e7baf089
|
||||||
VM UUID #3
|
|
||||||
...
|
|
||||||
```
|
```
|
||||||
|
32
main.py
32
main.py
@@ -31,18 +31,21 @@ def config_edit():
|
|||||||
while (vm_input != ""):
|
while (vm_input != ""):
|
||||||
vm_input = input(">> ")
|
vm_input = input(">> ")
|
||||||
file.write(vm_input + '\n')
|
file.write(vm_input + '\n')
|
||||||
|
print("UUIDs has been written in config")
|
||||||
|
print("\nConfiguration completed!")
|
||||||
if os.path.exists(config_relative_path) and os.path.getsize(config_relative_path) > 0: #check if file exists and not empty
|
if os.path.exists(config_relative_path) and os.path.getsize(config_relative_path) > 0: #check if file exists and not empty
|
||||||
#importing API-KEY / IP / DATA POOL UUID from config
|
pass #do nothing
|
||||||
with open(config_relative_path, "r") as f: # using '\' (instead of '\\') throws syntax warning
|
|
||||||
all_lines = f.readlines()
|
|
||||||
base_url = all_lines[0].strip('\n')
|
|
||||||
api_key = "jwt " + all_lines[1].strip('\n') #actual format for api_key. That was realy obvious DACOM >:C
|
|
||||||
data_pool_uuid = all_lines[2].strip('\n')
|
|
||||||
else:
|
else:
|
||||||
print("Config file was not found or empty.. ")
|
print("Config file was not found or empty.. ")
|
||||||
config_edit()
|
config_edit()
|
||||||
|
|
||||||
|
#importing API-KEY / IP / DATA POOL UUID from config
|
||||||
|
with open(config_relative_path, "r") as f:
|
||||||
|
all_lines = f.readlines()
|
||||||
|
base_url = all_lines[0].strip('\n')
|
||||||
|
api_key = "jwt " + all_lines[1].strip('\n') #actual format for api_key. That was realy obvious DACOM >:C
|
||||||
|
data_pool_uuid = all_lines[2].strip('\n')
|
||||||
|
|
||||||
#importing VM-UUIDs
|
#importing VM-UUIDs
|
||||||
vm_uuids = []
|
vm_uuids = []
|
||||||
with open(config_relative_path, "r") as f:
|
with open(config_relative_path, "r") as f:
|
||||||
@@ -57,13 +60,22 @@ with open(config_relative_path, "r") as f:
|
|||||||
#so-called INT MAIN
|
#so-called INT MAIN
|
||||||
menu_choice=0
|
menu_choice=0
|
||||||
while(menu_choice != ""): #main menu loop
|
while(menu_choice != ""): #main menu loop
|
||||||
read_input=input("\nUitility Main Menu: \n1) Edit config \n2) Enter disk edit mode \n3) Show breif cluster overview \n4) Show VM info \n>>> ")
|
read_input=input("\nUitility Main Menu: \n1) Manage utility config \n2) Enter disk edit mode \n3) Show breif cluster overview \n4) Show VM info \n>>> ")
|
||||||
menu_choice=str(read_input)
|
menu_choice=str(read_input)
|
||||||
|
|
||||||
if menu_choice == "1":
|
if menu_choice == "1":
|
||||||
config_edit()
|
|
||||||
if menu_choice == "2":
|
|
||||||
print("\033[H\033[2J", end="") # clears cmd screen, but saves scrollback buffer
|
print("\033[H\033[2J", end="") # clears cmd screen, but saves scrollback buffer
|
||||||
|
print("1) Show current configuration \n2) Change configuraion")
|
||||||
|
read_input=input(">> ")
|
||||||
|
menu_choice=int(read_input)
|
||||||
|
if menu_choice == 1:
|
||||||
|
print("Current configuration:\n")
|
||||||
|
with open(config_relative_path, "r") as f:
|
||||||
|
print(f.read())
|
||||||
|
if menu_choice == 2:
|
||||||
|
config_edit()
|
||||||
|
if menu_choice == "2":
|
||||||
|
print("\033[H\033[2J", end="")
|
||||||
print("Select option: \n 1) Delete vDisk by UUID \n 2) Delete ALL vDisks on selected Virtual Machine \n 3) Create Disk \n 4) Prepare VMs for Courses™")
|
print("Select option: \n 1) Delete vDisk by UUID \n 2) Delete ALL vDisks on selected Virtual Machine \n 3) Create Disk \n 4) Prepare VMs for Courses™")
|
||||||
read_input=input(">> ")
|
read_input=input(">> ")
|
||||||
menu_choice=int(read_input)
|
menu_choice=int(read_input)
|
||||||
|
Reference in New Issue
Block a user